summaryrefslogtreecommitdiff
path: root/src/utf8.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2025-04-02 17:45:11 +1100
committerMaxime Coste <mawww@kakoune.org>2025-04-02 17:45:11 +1100
commit424a7ee8aaaa5ac23355bcabcebf485e6a63c9c3 (patch)
tree2fa83399ec7fa40764f8c03d87fb0dfba9cc6ba9 /src/utf8.hh
parent63efcc06d5bee7f05a1ee9539b2391c80e5d6205 (diff)
Reduce include creep
Diffstat (limited to 'src/utf8.hh')
-rw-r--r--src/utf8.hh12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/utf8.hh b/src/utf8.hh
index e5643214..12be2861 100644
--- a/src/utf8.hh
+++ b/src/utf8.hh
@@ -4,7 +4,6 @@
#include "assert.hh"
#include "unicode.hh"
#include "units.hh"
-#include "optional.hh"
namespace Kakoune
{
@@ -263,14 +262,13 @@ Iterator character_start(Iterator it, const Sentinel& begin) noexcept
return it;
}
-// returns an optional iterator to the first byte of the previous character
-// or no value if it is at begin
-template<typename Iterator, typename Sentinel>
-static Optional<Codepoint> prev_codepoint(Iterator it, const Sentinel& begin) noexcept
+template<typename InvalidPolicy = utf8::InvalidPolicy::Pass,
+ typename Iterator, typename Sentinel>
+Codepoint prev_codepoint(Iterator it, const Sentinel& begin) noexcept
{
if (it <= begin)
- return {};
- return codepoint(character_start(it -1, begin), it);
+ return InvalidPolicy{}(-1);
+ return codepoint<InvalidPolicy>(character_start(it -1, begin), it);
}