diff --git a/libcxx/include/__string b/libcxx/include/__string --- a/libcxx/include/__string +++ b/libcxx/include/__string @@ -47,7 +47,9 @@ template <> struct char_traits; template <> struct char_traits; -template <> struct char_traits; // c++20 +template <> struct char_traits; // C++20 +template <> struct char_traits; +template <> struct char_traits; } // std diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -84,8 +84,11 @@ typedef basic_fstream wfstream; template class fpos; -typedef fpos::state_type> streampos; -typedef fpos::state_type> wstreampos; +using streampos = fpos::state_type>; +using wstreampos = fpos::state_type>; +using u8streampos = fpos::state_type>; // C++20 +using u16streampos = fpos::state_type>; +using u32streampos = fpos::state_type>; } // std diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -69,6 +69,9 @@ template <> struct char_traits; template <> struct char_traits; +template <> struct char_traits; // C++20 +template <> struct char_traits; +template <> struct char_traits; template, class Allocator = allocator > class basic_string @@ -450,6 +453,7 @@ typedef basic_string string; typedef basic_string wstring; +typedef basic_string u8string; // C++20 typedef basic_string u16string; typedef basic_string u32string; @@ -494,12 +498,14 @@ wstring to_wstring(long double val); template <> struct hash; +template <> struct hash; // C++20 template <> struct hash; template <> struct hash; template <> struct hash; basic_string operator "" s( const char *str, size_t len ); // C++14 basic_string operator "" s( const wchar_t *str, size_t len ); // C++14 +basic_string operator "" s( const char8_t *str, size_t len ); // C++20 basic_string operator "" s( const char16_t *str, size_t len ); // C++14 basic_string operator "" s( const char32_t *str, size_t len ); // C++14 diff --git a/libcxx/include/string_view b/libcxx/include/string_view --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -48,6 +48,7 @@ // basic_string_view typedef names typedef basic_string_view string_view; + typedef basic_string_view u8string_view; // C++20 typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; typedef basic_string_view wstring_view; @@ -161,12 +162,14 @@ // 7.11, Hash support template struct hash; template <> struct hash; + template <> struct hash; // C++20 template <> struct hash; template <> struct hash; template <> struct hash; constexpr basic_string_view operator "" sv( const char *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const wchar_t *str, size_t len ) noexcept; + constexpr basic_string_view operator "" sv( const char8_t *str, size_t len ) noexcept; // C++20 constexpr basic_string_view operator "" sv( const char16_t *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const char32_t *str, size_t len ) noexcept; diff --git a/libcxx/test/std/language.support/support.limits/limits/is_specialized.pass.cpp b/libcxx/test/std/language.support/support.limits/limits/is_specialized.pass.cpp --- a/libcxx/test/std/language.support/support.limits/limits/is_specialized.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/limits/is_specialized.pass.cpp @@ -46,6 +46,9 @@ test(); test(); test(); +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) + test(); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS test(); test(); diff --git a/libcxx/test/std/strings/basic.string.hash/char_type_hash.fail.cpp b/libcxx/test/std/strings/basic.string.hash/char_type_hash.fail.cpp --- a/libcxx/test/std/strings/basic.string.hash/char_type_hash.fail.cpp +++ b/libcxx/test/std/strings/basic.string.hash/char_type_hash.fail.cpp @@ -17,6 +17,8 @@ #include +#include "test_macros.h" + template struct trait // copied from <__string> { @@ -57,12 +59,18 @@ typedef std::basic_string > str_t; std::hash h; // expected-error-re 4 {{{{call to implicitly-deleted default constructor of 'std::hash'|implicit instantiation of undefined template}} {{.+}}}}}} +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) + // expected-error-re@-2 {{{{call to implicitly-deleted default constructor of 'std::hash'|implicit instantiation of undefined template}} {{.+}}}}}} +#endif (void)h; } int main(int, char**) { test(); test(); +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) + test(); +#endif test(); test(); diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp --- a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp @@ -11,10 +11,10 @@ // template<> struct char_traits -// typedef char8_t char_type; +// typedef char8_t char_type; // typedef unsigned int int_type; // typedef streamoff off_type; -// typedef u16streampos pos_type; +// typedef u8streampos pos_type; // typedef mbstate_t state_type; #include @@ -29,7 +29,7 @@ static_assert((std::is_same::char_type, char8_t>::value), ""); static_assert((std::is_same::int_type, unsigned int>::value), ""); static_assert((std::is_same::off_type, std::streamoff>::value), ""); - static_assert((std::is_same::pos_type, std::u16streampos>::value), ""); + static_assert((std::is_same::pos_type, std::u8streampos>::value), ""); static_assert((std::is_same::state_type, std::mbstate_t>::value), ""); #endif diff --git a/libcxx/test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp b/libcxx/test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp --- a/libcxx/test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp +++ b/libcxx/test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp @@ -18,6 +18,8 @@ #include #include // for 'mbstate_t' +#include "test_macros.h" + template struct trait // copied from <__string> { @@ -58,12 +60,18 @@ typedef std::basic_string_view > strv_t; std::hash h; // expected-error-re 4 {{{{call to implicitly-deleted default constructor of 'std::hash'|implicit instantiation of undefined template}} {{.+}}}}}} +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) + // expected-error-re@-2 {{{{call to implicitly-deleted default constructor of 'std::hash'|implicit instantiation of undefined template}} {{.+}}}}}} +#endif (void)h; } int main(int, char**) { test(); test(); +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) + test(); +#endif test(); test();