diff options
-rw-r--r-- | lib/unicode.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/unicode.h b/lib/unicode.h index 2945650..f69c43c 100644 --- a/lib/unicode.h +++ b/lib/unicode.h @@ -45,25 +45,30 @@ struct utf8_string_view { const char * pos; }; + template<typename Str> // cppcheck-suppress noExplicitConstructor; NOLINTNEXTLINE(hicpp-explicit-conversions) - template<typename... Args> constexpr utf8_string_view(Args &&... args) : str {std::forward<Args>(args)...} { } + constexpr utf8_string_view(const Str & str) : begin_ {str.data()}, end_ {str.data() + str.length()} + { + } + // cppcheck-suppress noExplicitConstructor; NOLINTNEXTLINE(hicpp-explicit-conversions) + constexpr utf8_string_view(const char * const str) : utf8_string_view {std::string_view {str}} { } [[nodiscard]] auto begin() const { - return iter {str.cbegin()}; + return iter {begin_}; } [[nodiscard]] auto end() const { - return iter {str.cend()}; + return iter {end_}; } [[nodiscard]] size_t length() const; private: - std::string_view str; + const char *begin_, *end_; }; template<> struct std::iterator_traits<utf8_string_view::iter> { using difference_type = size_t; |