Skip to content

Commit de9ca6c

Browse files
committed
basic_string<Ch> optimization was implemented.
1 parent c3b871d commit de9ca6c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

include/ww898/utf_converters.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,20 @@ Oit conv(std::basic_string_view<Ch> const & str, Oit && oit)
584584

585585
template<
586586
typename Och,
587-
typename Str>
587+
typename Str,
588+
typename std::enable_if<!std::is_same<typename std::decay<Str>::type, std::basic_string<Och>>::value, void *>::type = nullptr>
588589
std::basic_string<Och> conv(Str && str)
589590
{
590591
std::basic_string<Och> res;
591592
conv<utf_selector_t<Och>>(std::forward<Str>(str), std::back_inserter(res));
592593
return res;
593594
}
594595

596+
template<
597+
typename Ch>
598+
std::basic_string<Ch> conv(std::basic_string<Ch> str) noexcept
599+
{
600+
return str;
601+
}
602+
595603
}}

test/utf_converters_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
*/
2424

2525
#if defined(_WIN32)
26+
#if !defined(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
2627
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
2728
#endif
29+
#endif
2830

2931
#include <ww898/utf_converters.hpp>
3032

@@ -913,6 +915,7 @@ BOOST_AUTO_TEST_CASE(example, WW898_PERFORMANCE_TESTS_MODE)
913915
std::wstring uw;
914916
conv<utf8, utfw>(u8s, u8s + sizeof(u8s), std::back_inserter(uw));
915917
auto u8r = conv<char>(uw);
918+
auto u16r = conv<char16_t>(u16);
916919
auto uwr = convz<wchar_t>(u8s);
917920

918921
#if __cpp_lib_string_view >= 201606

0 commit comments

Comments
 (0)