diff --git a/benchmarks/conversion_speed/source/standard_c++.cpp b/benchmarks/conversion_speed/source/standard_c++.cpp index 347e240b..4dfe64e7 100644 --- a/benchmarks/conversion_speed/source/standard_c++.cpp +++ b/benchmarks/conversion_speed/source/standard_c++.cpp @@ -33,7 +33,7 @@ #include -#if (ZTD_IS_ON(ZTD_UCHAR) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) +#if (ZTD_IS_ON(ZTD_UCHAR_H) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) #include diff --git a/benchmarks/conversion_speed/source/standard_c++.init.cpp b/benchmarks/conversion_speed/source/standard_c++.init.cpp index f90597db..a80eb174 100644 --- a/benchmarks/conversion_speed/source/standard_c++.init.cpp +++ b/benchmarks/conversion_speed/source/standard_c++.init.cpp @@ -33,7 +33,7 @@ #include -#if (ZTD_IS_ON(ZTD_UCHAR) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) +#if (ZTD_IS_ON(ZTD_UCHAR_H) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) #include diff --git a/benchmarks/conversion_speed/source/standard_c.cpp b/benchmarks/conversion_speed/source/standard_c.cpp index 28861dfd..bfc98a62 100644 --- a/benchmarks/conversion_speed/source/standard_c.cpp +++ b/benchmarks/conversion_speed/source/standard_c.cpp @@ -33,7 +33,7 @@ #include -#if (ZTD_IS_ON(ZTD_UCHAR) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) +#if (ZTD_IS_ON(ZTD_UCHAR_H) || ZTD_IS_ON(ZTD_CUCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) #include @@ -65,7 +65,7 @@ static void utf16_to_utf32_well_formed_standard_c(benchmark::State& state) { const from_char_t* const input_last = input_data.data() + input_data.size(); for (;;) { if (input != input_last) { - const size_t from_result = ZTD_UCHAR_ACCESSOR_I_ c16rtomb(intermediate, *input, &from_state); + const size_t from_result = ZTD_UCHAR_SCOPE_I_ c16rtomb(intermediate, *input, &from_state); switch (from_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -80,7 +80,7 @@ static void utf16_to_utf32_well_formed_standard_c(benchmark::State& state) { } const size_t intermediate_size = from_result + (intermediate - intermediate_data); const size_t to_result - = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(output, intermediate_data, intermediate_size, &to_state); + = ZTD_UCHAR_SCOPE_I_ mbrtoc32(output, intermediate_data, intermediate_size, &to_state); switch (to_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -110,10 +110,10 @@ static void utf16_to_utf32_well_formed_standard_c(benchmark::State& state) { // finish processing text without having to check if you have cleaned out // the state. You have to call the function more to make sure // you have drained off all the surrogates... - while (ZTD_UCHAR_ACCESSOR_I_ mbsinit(&to_state) == 0) { + while (ZTD_UCHAR_SCOPE_I_ mbsinit(&to_state) == 0) { // try to drain the (last?) input out... to_char_t last_c; - const size_t last_to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(&last_c, "", 1, &to_state); + const size_t last_to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc32(&last_c, "", 1, &to_state); if (last_to_result == static_cast(-3)) { // we had extra, vomit it out... *output = last_c; @@ -159,7 +159,7 @@ static void utf32_to_utf16_well_formed_standard_c(benchmark::State& state) { const from_char_t* const input_last = input_data.data() + input_data.size(); for (;;) { if (input != input_last) { - const size_t from_result = ZTD_UCHAR_ACCESSOR_I_ c32rtomb(intermediate, *input, &from_state); + const size_t from_result = ZTD_UCHAR_SCOPE_I_ c32rtomb(intermediate, *input, &from_state); switch (from_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -174,7 +174,7 @@ static void utf32_to_utf16_well_formed_standard_c(benchmark::State& state) { } const size_t intermediate_size = from_result + (intermediate - intermediate_data); const size_t to_result - = ZTD_UCHAR_ACCESSOR_I_ mbrtoc16(output, intermediate_data, intermediate_size, &to_state); + = ZTD_UCHAR_SCOPE_I_ mbrtoc16(output, intermediate_data, intermediate_size, &to_state); switch (to_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -205,10 +205,10 @@ static void utf32_to_utf16_well_formed_standard_c(benchmark::State& state) { // finish processing text without having to check if you have cleaned out // the state. You have to call the function more to make sure // you have drained off all the surrogates... - while (ZTD_UCHAR_ACCESSOR_I_ mbsinit(&to_state) == 0) { + while (ZTD_UCHAR_SCOPE_I_ mbsinit(&to_state) == 0) { // try to drain the (last?) input out... to_char_t last_c; - const size_t last_to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc16(&last_c, "", 1, &to_state); + const size_t last_to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc16(&last_c, "", 1, &to_state); if (last_to_result == static_cast(-3)) { // we had extra, vomit it out... *output = last_c; @@ -250,7 +250,7 @@ static void utf32_to_utf8_well_formed_standard_c(benchmark::State& state) { const from_char_t* input = input_data.data(); const from_char_t* const input_last = input_data.data() + input_data.size(); for (; input != input_last;) { - const size_t from_result = ZTD_UCHAR_ACCESSOR_I_ c32rtomb(output, *input, &from_state); + const size_t from_result = ZTD_UCHAR_SCOPE_I_ c32rtomb(output, *input, &from_state); switch (from_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -294,7 +294,7 @@ static void utf8_to_utf32_well_formed_standard_c(benchmark::State& state) { for (;;) { if (input != input_last) { const std::size_t input_size = input_last - input; - const size_t to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(output, input, input_size, &to_state); + const size_t to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc32(output, input, input_size, &to_state); switch (to_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -323,10 +323,10 @@ static void utf8_to_utf32_well_formed_standard_c(benchmark::State& state) { // finish processing text without having to check if you have cleaned out // the state. You have to call the function more to make sure // you have drained off all the surrogates... - while (ZTD_UCHAR_ACCESSOR_I_ mbsinit(&to_state) == 0) { + while (ZTD_UCHAR_SCOPE_I_ mbsinit(&to_state) == 0) { // try to drain the (last?) input out... to_char_t last_c; - const size_t last_to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(&last_c, "", 1, &to_state); + const size_t last_to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc32(&last_c, "", 1, &to_state); if (last_to_result == static_cast(-3)) { // we had extra, vomit it out... *output = last_c; @@ -368,7 +368,7 @@ static void utf16_to_utf8_well_formed_standard_c(benchmark::State& state) { const from_char_t* input = input_data.data(); const from_char_t* const input_last = input_data.data() + input_data.size(); for (; input != input_last;) { - const size_t from_result = ZTD_UCHAR_ACCESSOR_I_ c16rtomb(output, *input, &from_state); + const size_t from_result = ZTD_UCHAR_SCOPE_I_ c16rtomb(output, *input, &from_state); switch (from_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -412,7 +412,7 @@ static void utf8_to_utf16_well_formed_standard_c(benchmark::State& state) { for (;;) { if (input != input_last) { const std::size_t input_size = input_last - input; - const size_t to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc16(output, input, input_size, &to_state); + const size_t to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc16(output, input, input_size, &to_state); switch (to_result) { case static_cast(-1): // encoding error: everyhting has failed. bail. @@ -441,10 +441,10 @@ static void utf8_to_utf16_well_formed_standard_c(benchmark::State& state) { // finish processing text without having to check if you have cleaned out // the state. You have to call the function more to make sure // you have drained off all the surrogates... - while (ZTD_UCHAR_ACCESSOR_I_ mbsinit(&to_state) == 0) { + while (ZTD_UCHAR_SCOPE_I_ mbsinit(&to_state) == 0) { // try to drain the (last?) input out... to_char_t last_c; - const size_t last_to_result = ZTD_UCHAR_ACCESSOR_I_ mbrtoc16(&last_c, "", 1, &to_state); + const size_t last_to_result = ZTD_UCHAR_SCOPE_I_ mbrtoc16(&last_c, "", 1, &to_state); if (last_to_result == static_cast(-3)) { // we had extra, vomit it out... *output = last_c; diff --git a/include/ztd/text/execution.hpp b/include/ztd/text/execution.hpp index d5a2e226..da9974dd 100644 --- a/include/ztd/text/execution.hpp +++ b/include/ztd/text/execution.hpp @@ -60,7 +60,7 @@ namespace ztd { namespace text { /// Standard Library and bugs in glibc/musl libc's current locale encoding support. On Apple, this is cuurrently /// assumed to be UTF-8 since they do not support the @c \ or @c \ headers. class execution_t : public -#if (ZTD_IS_ON(ZTD_CUCHAR) || ZTD_IS_ON(ZTD_UCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) +#if (ZTD_IS_ON(ZTD_CUCHAR) || ZTD_IS_ON(ZTD_UCHAR_H)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) __txt_impl::__execution_cuchar #elif ZTD_IS_ON(ZTD_PLATFORM_MAC_OS) __txt_impl::__execution_mac_os diff --git a/include/ztd/text/impl/execution_cuchar.hpp b/include/ztd/text/impl/execution_cuchar.hpp index 25901446..f551d7a3 100644 --- a/include/ztd/text/impl/execution_cuchar.hpp +++ b/include/ztd/text/impl/execution_cuchar.hpp @@ -51,9 +51,10 @@ #include #include #include +#include #include -#if (ZTD_IS_ON(ZTD_CUCHAR) || ZTD_IS_ON(ZTD_UCHAR)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) +#if (ZTD_IS_ON(ZTD_CUCHAR) || ZTD_IS_ON(ZTD_UCHAR_H)) && ZTD_IS_OFF(ZTD_PLATFORM_MAC_OS) // clang-format off #if ZTD_IS_ON(ZTD_CUCHAR) @@ -75,13 +76,12 @@ namespace ztd { namespace text { namespace __txt_detail { class __execution_decode_state { public: - ::std::mbstate_t __narrow_state; + ztd_mbstate_t __narrow_state; bool __output_pending; __execution_decode_state() noexcept : __narrow_state(), __output_pending(false) { ztd_char32_t __ghost_space[2]; - ::std::size_t __init_result - = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(__ghost_space, "\0", 1, &__narrow_state); + ::std::size_t __init_result = ZTD_UCHAR_SCOPE_I_ mbrtoc32(__ghost_space, "\0", 1, &__narrow_state); // make sure it is initialized ZTD_TEXT_ASSERT_I_(__init_result == 0 && __ghost_space[0] == U'\0'); ZTD_TEXT_ASSERT_I_(::std::mbsinit(&__narrow_state) != 0); @@ -90,12 +90,12 @@ namespace ztd { namespace text { class __execution_encode_state { public: - ::std::mbstate_t __narrow_state; + ztd_mbstate_t __narrow_state; bool __output_pending; __execution_encode_state() noexcept : __narrow_state(), __output_pending(false) { char __ghost_space[MB_LEN_MAX]; - ::std::size_t __init_result = ZTD_UCHAR_ACCESSOR_I_ c32rtomb(__ghost_space, U'\0', &__narrow_state); + ::std::size_t __init_result = ZTD_UCHAR_SCOPE_I_ c32rtomb(__ghost_space, U'\0', &__narrow_state); // make sure it is initialized ZTD_TEXT_ASSERT_I_(__init_result == 1 && __ghost_space[0] == '\0'); ZTD_TEXT_ASSERT_I_(::std::mbsinit(&__narrow_state) != 0); @@ -336,7 +336,7 @@ namespace ztd { namespace text { code_point __codepoint = *__in_it; ::ztd::ranges::iter_advance(__in_it); code_unit __intermediary_output[(MB_LEN_MAX)] {}; - ::std::size_t __res = ZTD_UCHAR_ACCESSOR_I_ c32rtomb( + ::std::size_t __res = ZTD_UCHAR_SCOPE_I_ c32rtomb( __intermediary_output, __codepoint, ::std::addressof(__s.__narrow_state)); if constexpr (__call_error_handler) { if (__res == static_cast<::std::size_t>(-1)) { @@ -502,9 +502,8 @@ namespace ztd { namespace text { if (__s.__output_pending) { // need to drain potential mbstate_t of any leftover code points? ztd_char32_t __intermediary_output[max_code_points] {}; - ::std::size_t __res - = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32(::std::addressof(__intermediary_output[0]), nullptr, 0, - ::std::addressof(__s.__narrow_state)); + ::std::size_t __res = ZTD_UCHAR_SCOPE_I_ mbrtoc32(::std::addressof(__intermediary_output[0]), + nullptr, 0, ::std::addressof(__s.__narrow_state)); if constexpr (__call_error_handler) { if (__res == static_cast<::std::size_t>(-1)) { __execution_cuchar __self {}; @@ -529,9 +528,9 @@ namespace ztd { namespace text { __intermediary_input[__state_offset] = *__in_it; ::ztd::ranges::iter_advance(__in_it); ztd_char32_t __intermediary_output[1] {}; - ::std::size_t __res = ZTD_UCHAR_ACCESSOR_I_ mbrtoc32( - ::std::addressof(__intermediary_output[0]), ::std::addressof(__intermediary_input[0]), - __state_count, ::std::addressof(__preserved_state)); + ::std::size_t __res = ZTD_UCHAR_SCOPE_I_ mbrtoc32(::std::addressof(__intermediary_output[0]), + ::std::addressof(__intermediary_input[0]), __state_count, + ::std::addressof(__preserved_state)); switch (__res) { case static_cast<::std::size_t>(-2): diff --git a/include/ztd/text/impl/wide_execution_cwchar.hpp b/include/ztd/text/impl/wide_execution_cwchar.hpp index d39e8626..79d79a0a 100644 --- a/include/ztd/text/impl/wide_execution_cwchar.hpp +++ b/include/ztd/text/impl/wide_execution_cwchar.hpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -62,7 +63,7 @@ namespace ztd { namespace text { class __wide_execution_decode_state { public: - ::std::mbstate_t __wide_state; + ztd_mbstate_t __wide_state; decode_state_t __narrow_state; __wide_execution_decode_state() noexcept : __wide_state(), __narrow_state() { diff --git a/include/ztd/text/unicode_code_point.hpp b/include/ztd/text/unicode_code_point.hpp index 78b41ad8..6d2c3f37 100644 --- a/include/ztd/text/unicode_code_point.hpp +++ b/include/ztd/text/unicode_code_point.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -145,102 +146,102 @@ namespace ztd { namespace text { namespace std { - template <> - class char_traits<::ztd::text::__txt_impl::__unicode_code_point> { - using char_type = ::ztd::text::__txt_impl::__unicode_code_point; - using int_type = ::std::int_least32_t; - using pos_type = ::std::streampos; - using off_type = ::std::streamoff; - using state_type = ::std::mbstate_t; - - static constexpr char_type* copy( - char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { - (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); - return __destination; - } - - static constexpr char_type* move( - char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { - (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); - return __destination; - } - - ZTD_NODISCARD_I_ static constexpr int compare( - const char_type* __left, const char_type* __right, ::std::size_t __count) noexcept { - if (__count == 0) { - return 0; - } - return ::ztd::ranges::__rng_detail::__lexicographical_compare_three_way_basic( - __left, __left + __count, __right, __right + __count); - } - - ZTD_NODISCARD_I_ static constexpr size_t length(const char_type* __it) noexcept { - size_t __count = 0; - const char_type __null_value {}; - while (*__it != __null_value) { - ++__count; - ++__it; - } - return __count; - } - - ZTD_NODISCARD_I_ static constexpr const char_type* find( - const char_type* __it, size_t __count, const char_type& __c) noexcept { - for (; 0 < __count; --__count, (void)++__it) { - if (*__it == __c) { - return __it; - } +template <> +class char_traits<::ztd::text::__txt_impl::__unicode_code_point> { + using char_type = ::ztd::text::__txt_impl::__unicode_code_point; + using int_type = ::std::int_least32_t; + using pos_type = ::std::streampos; + using off_type = ::std::streamoff; + using state_type = ztd_mbstate_t; + + static constexpr char_type* copy( + char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { + (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); + return __destination; + } + + static constexpr char_type* move( + char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { + (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); + return __destination; + } + + ZTD_NODISCARD_I_ static constexpr int compare( + const char_type* __left, const char_type* __right, ::std::size_t __count) noexcept { + if (__count == 0) { + return 0; + } + return ::ztd::ranges::__rng_detail::__lexicographical_compare_three_way_basic( + __left, __left + __count, __right, __right + __count); + } + + ZTD_NODISCARD_I_ static constexpr size_t length(const char_type* __it) noexcept { + size_t __count = 0; + const char_type __null_value {}; + while (*__it != __null_value) { + ++__count; + ++__it; + } + return __count; + } + + ZTD_NODISCARD_I_ static constexpr const char_type* find( + const char_type* __it, size_t __count, const char_type& __c) noexcept { + for (; 0 < __count; --__count, (void)++__it) { + if (*__it == __c) { + return __it; } - return nullptr; } + return nullptr; + } - static constexpr char_type* assign(char_type* __first, size_t __count, const char_type __c) noexcept { - for (char_type* __it = __first; __count > 0; --__count, (void)++__it) { - *__it = __c; - } - return __first; + static constexpr char_type* assign(char_type* __first, size_t __count, const char_type __c) noexcept { + for (char_type* __it = __first; __count > 0; --__count, (void)++__it) { + *__it = __c; } + return __first; + } - static constexpr void assign(char_type& __left, const char_type& __right) noexcept { - __left = __right; - } + static constexpr void assign(char_type& __left, const char_type& __right) noexcept { + __left = __right; + } - ZTD_NODISCARD_I_ static constexpr bool eq(const char_type& __left, const char_type& __right) noexcept { - return __left == __right; - } + ZTD_NODISCARD_I_ static constexpr bool eq(const char_type& __left, const char_type& __right) noexcept { + return __left == __right; + } - ZTD_NODISCARD_I_ static constexpr bool lt(const char_type& __left, const char_type& __right) noexcept { - return __left < __right; - } + ZTD_NODISCARD_I_ static constexpr bool lt(const char_type& __left, const char_type& __right) noexcept { + return __left < __right; + } - ZTD_NODISCARD_I_ static constexpr char_type to_char_type(const int_type& __c_as_int) noexcept { - return char_type(static_cast(__c_as_int)); - } + ZTD_NODISCARD_I_ static constexpr char_type to_char_type(const int_type& __c_as_int) noexcept { + return char_type(static_cast(__c_as_int)); + } - ZTD_NODISCARD_I_ static constexpr int_type to_int_type(const char_type& __c) noexcept { - return static_cast(__c.value()); - } + ZTD_NODISCARD_I_ static constexpr int_type to_int_type(const char_type& __c) noexcept { + return static_cast(__c.value()); + } - ZTD_NODISCARD_I_ static constexpr bool eq_int_type(const int_type& __left, const int_type& __right) noexcept { - return __left == __right; - } + ZTD_NODISCARD_I_ static constexpr bool eq_int_type(const int_type& __left, const int_type& __right) noexcept { + return __left == __right; + } - ZTD_NODISCARD_I_ static constexpr int_type not_eof(const int_type& __c_as_int) noexcept { - return __c_as_int != eof() ? __c_as_int : !eof(); - } + ZTD_NODISCARD_I_ static constexpr int_type not_eof(const int_type& __c_as_int) noexcept { + return __c_as_int != eof() ? __c_as_int : !eof(); + } - ZTD_NODISCARD_I_ static constexpr int_type eof() noexcept { - return static_cast(EOF); - } - }; + ZTD_NODISCARD_I_ static constexpr int_type eof() noexcept { + return static_cast(EOF); + } +}; } // namespace std namespace ztd { - template <> - class is_character<::ztd::text::__txt_impl::__unicode_code_point> : public ::std::true_type { }; +template <> +class is_character<::ztd::text::__txt_impl::__unicode_code_point> : public ::std::true_type { }; - template <> - class is_char_traitable<::ztd::text::__txt_impl::__unicode_code_point> : public std::true_type { }; +template <> +class is_char_traitable<::ztd::text::__txt_impl::__unicode_code_point> : public std::true_type { }; } // namespace ztd #include diff --git a/include/ztd/text/unicode_scalar_value.hpp b/include/ztd/text/unicode_scalar_value.hpp index abc59043..9413fa9e 100644 --- a/include/ztd/text/unicode_scalar_value.hpp +++ b/include/ztd/text/unicode_scalar_value.hpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -152,103 +153,103 @@ namespace ztd { namespace text { namespace std { - template <> - class char_traits<::ztd::text::__txt_impl::__unicode_scalar_value> { - using char_type = ::ztd::text::__txt_impl::__unicode_scalar_value; - using int_type = ::std::int_least32_t; - using pos_type = ::std::streampos; - using off_type = ::std::streamoff; - using state_type = ::std::mbstate_t; - - static constexpr char_type* copy( - char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { - (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); - return __destination; +template <> +class char_traits<::ztd::text::__txt_impl::__unicode_scalar_value> { + using char_type = ::ztd::text::__txt_impl::__unicode_scalar_value; + using int_type = ::std::int_least32_t; + using pos_type = ::std::streampos; + using off_type = ::std::streamoff; + using state_type = ztd_mbstate_t; + + static constexpr char_type* copy( + char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { + (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); + return __destination; + } + + static constexpr char_type* move( + char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { + (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); + return __destination; + } + + ZTD_NODISCARD_I_ static constexpr int compare( + const char_type* __left, const char_type* __right, ::std::size_t __count) noexcept { + if (__count == 0) { + return 0; } - - static constexpr char_type* move( - char_type* __destination, const char_type* __source, ::std::size_t __count) noexcept { - (void)::ztd::ranges::__rng_detail::__copy_n_unsafe(__source, __count, __destination); - return __destination; + return ::ztd::ranges::__rng_detail::__lexicographical_compare_three_way_basic( + __left, __left + __count, __right, __right + __count); + } + + ZTD_NODISCARD_I_ static constexpr size_t length(const char_type* __it) noexcept { + size_t __count = 0; + const char_type __null_value {}; + while (*__it != __null_value) { + ++__count; + ++__it; } - - ZTD_NODISCARD_I_ static constexpr int compare( - const char_type* __left, const char_type* __right, ::std::size_t __count) noexcept { - if (__count == 0) { - return 0; - } - return ::ztd::ranges::__rng_detail::__lexicographical_compare_three_way_basic( - __left, __left + __count, __right, __right + __count); - } - - ZTD_NODISCARD_I_ static constexpr size_t length(const char_type* __it) noexcept { - size_t __count = 0; - const char_type __null_value {}; - while (*__it != __null_value) { - ++__count; - ++__it; - } - return __count; - } - - ZTD_NODISCARD_I_ static constexpr const char_type* find( - const char_type* __it, size_t __count, const char_type& __c) noexcept { - for (; 0 < __count; --__count, (void)++__it) { - if (*__it == __c) { - return __it; - } + return __count; + } + + ZTD_NODISCARD_I_ static constexpr const char_type* find( + const char_type* __it, size_t __count, const char_type& __c) noexcept { + for (; 0 < __count; --__count, (void)++__it) { + if (*__it == __c) { + return __it; } - return nullptr; } + return nullptr; + } - static constexpr char_type* assign(char_type* __first, size_t __count, const char_type __c) noexcept { - for (char_type* __it = __first; __count > 0; --__count, (void)++__it) { - *__it = __c; - } - return __first; + static constexpr char_type* assign(char_type* __first, size_t __count, const char_type __c) noexcept { + for (char_type* __it = __first; __count > 0; --__count, (void)++__it) { + *__it = __c; } + return __first; + } - static constexpr void assign(char_type& __left, const char_type& __right) noexcept { - __left = __right; - } + static constexpr void assign(char_type& __left, const char_type& __right) noexcept { + __left = __right; + } - ZTD_NODISCARD_I_ static constexpr bool eq(const char_type& __left, const char_type& __right) noexcept { - return __left == __right; - } + ZTD_NODISCARD_I_ static constexpr bool eq(const char_type& __left, const char_type& __right) noexcept { + return __left == __right; + } - ZTD_NODISCARD_I_ static constexpr bool lt(const char_type& __left, const char_type& __right) noexcept { - return __left < __right; - } + ZTD_NODISCARD_I_ static constexpr bool lt(const char_type& __left, const char_type& __right) noexcept { + return __left < __right; + } - ZTD_NODISCARD_I_ static constexpr char_type to_char_type(const int_type& __c_as_int) noexcept { - return char_type(static_cast(__c_as_int)); - } + ZTD_NODISCARD_I_ static constexpr char_type to_char_type(const int_type& __c_as_int) noexcept { + return char_type(static_cast(__c_as_int)); + } - ZTD_NODISCARD_I_ static constexpr int_type to_int_type(const char_type& __c) noexcept { - return static_cast(__c.value()); - } + ZTD_NODISCARD_I_ static constexpr int_type to_int_type(const char_type& __c) noexcept { + return static_cast(__c.value()); + } - ZTD_NODISCARD_I_ static constexpr bool eq_int_type(const int_type& __left, const int_type& __right) noexcept { - return __left == __right; - } + ZTD_NODISCARD_I_ static constexpr bool eq_int_type(const int_type& __left, const int_type& __right) noexcept { + return __left == __right; + } - ZTD_NODISCARD_I_ static constexpr int_type not_eof(const int_type& __c_as_int) noexcept { - return __c_as_int != eof() ? __c_as_int : !eof(); - } + ZTD_NODISCARD_I_ static constexpr int_type not_eof(const int_type& __c_as_int) noexcept { + return __c_as_int != eof() ? __c_as_int : !eof(); + } - ZTD_NODISCARD_I_ static constexpr int_type eof() noexcept { - return static_cast(EOF); - } - }; + ZTD_NODISCARD_I_ static constexpr int_type eof() noexcept { + return static_cast(EOF); + } +}; } // namespace std namespace ztd { - template <> - class is_character<::ztd::text::unicode_scalar_value> : public ::std::true_type { }; +template <> +class is_character<::ztd::text::unicode_scalar_value> : public ::std::true_type { }; - template <> - class is_char_traitable<::ztd::text::unicode_scalar_value> : public std::true_type { }; +template <> +class is_char_traitable<::ztd::text::unicode_scalar_value> : public std::true_type { }; } // namespace ztd #include