#define _TINY_UTF8_H_USE_IOSTREAM_ #include "tinyutf8/tinyutf8.h" #include class utf8_string_regex_traits : public std::regex_traits { public: using char_type = utf8_string::value_type; using string_type = utf8_string; using locale_type = std::locale; using char_class_type = std::regex_traits::char_class_type; utf8_string_regex_traits() = default; static std::size_t length(const char_type* p) { return string_type(p).length(); } char_type translate(char_type c) const { return c; } char_type translate_nocase(char_type c) const { return std::use_facet>(getloc()).tolower(c); } // template // string_type transform(ForwardIt first, ForwardIt last) const { // string_type str(first, last); // return std::use_facet>(getloc()) // .transform(str.begin(), str.begin() + str.length()); // } // template // string_type transform_primary(ForwardIt first, ForwardIt last) const { // std::regex_traits tmp; // tmp.imbue(getloc()); // return tmp.transform_primary(first, last); // } // template // char_class_type lookup_classname(ForwardIt first, // ForwardIt last, bool icase = false) const { // return std::wctype(std::string(first, last).c_str()); // } // bool isctype(char_type c, char_class_type f) const { // return std::iswctype(c, static_cast(f)); // } // int value(char_type ch, int radix) const { // return std::regex_traits::value(ch, radix); // } // locale_type imbue(locale_type loc) { // locale_type o_loc = std::move(m_loc); // m_loc = loc; // return o_loc; // } // locale_type getloc() const { // return m_loc; // } private: // locale_type m_loc; };