Index: include/__string =================================================================== --- include/__string +++ include/__string @@ -47,6 +47,7 @@ template <> struct char_traits; template <> struct char_traits; +template <> struct char_traits; // c++20 } // std @@ -389,6 +390,102 @@ } +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) + +template <> +struct _LIBCPP_TEMPLATE_VIS char_traits +{ + typedef char8_t char_type; + typedef unsigned int int_type; + typedef streamoff off_type; + typedef u8streampos pos_type; + typedef mbstate_t state_type; + + static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept + {__c1 = __c2;} + static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept + {return __c1 == __c2;} + static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept + {return __c1 < __c2;} + + static constexpr + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + + static constexpr + size_t length(const char_type* __s) _NOEXCEPT; + + _LIBCPP_INLINE_VISIBILITY static constexpr + const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; + + static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT + {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} + + static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT + { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); + } + + static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT + {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} + + static inline constexpr int_type not_eof(int_type __c) noexcept + {return eq_int_type(__c, eof()) ? ~eof() : __c;} + static inline constexpr char_type to_char_type(int_type __c) noexcept + {return char_type(__c);} + static inline constexpr int_type to_int_type(char_type __c) noexcept + {return int_type(__c);} + static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept + {return __c1 == __c2;} + static inline constexpr int_type eof() noexcept + {return int_type(EOF);} +}; + +// TODO use '__builtin_strlen' if it ever supports char8_t ?? +inline constexpr +size_t +char_traits::length(const char_type* __s) _NOEXCEPT +{ + size_t __len = 0; + for (; !eq(*__s, char_type(0)); ++__s) + ++__len; + return __len; +} + +inline constexpr +int +char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT +{ +#if __has_feature(cxx_constexpr_string_builtins) + return __builtin_memcmp(__s1, __s2, __n); +#else + for (; __n; --__n, ++__s1, ++__s2) + { + if (lt(*__s1, *__s2)) + return -1; + if (lt(*__s2, *__s1)) + return 1; + } + return 0; +#endif +} + +// TODO use '__builtin_char_memchr' if it ever supports char8_t ?? +inline constexpr +const char8_t* +char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT +{ + for (; __n; --__n) + { + if (eq(*__s, __a)) + return __s; + ++__s; + } + return 0; +} + +#endif // _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> Index: include/iosfwd =================================================================== --- include/iosfwd +++ include/iosfwd @@ -18,6 +18,12 @@ { template struct char_traits; +template<> struct char_traits; +template<> struct char_traits; // C++20 +template<> struct char_traits; +template<> struct char_traits; +template<> struct char_traits; + template class allocator; class ios_base; @@ -98,6 +104,14 @@ class _LIBCPP_TYPE_VIS ios_base; template struct _LIBCPP_TEMPLATE_VIS char_traits; +template<> struct char_traits; +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) +template<> struct char_traits; +#endif +template<> struct char_traits; +template<> struct char_traits; +template<> struct char_traits; + template class _LIBCPP_TEMPLATE_VIS allocator; template > @@ -175,6 +189,9 @@ template class _LIBCPP_TEMPLATE_VIS fpos; typedef fpos streampos; typedef fpos wstreampos; +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) +typedef fpos u8streampos; +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS typedef fpos u16streampos; typedef fpos u32streampos; Index: include/istream =================================================================== --- include/istream +++ include/istream @@ -160,6 +160,7 @@ */ #include <__config> +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) Index: include/limits =================================================================== --- include/limits +++ include/limits @@ -119,6 +119,7 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#include _LIBCPP_BEGIN_NAMESPACE_STD Index: include/locale =================================================================== --- include/locale +++ include/locale @@ -187,6 +187,7 @@ #include #include #include +#include #ifndef __APPLE__ #include #endif Index: include/ostream =================================================================== --- include/ostream +++ include/ostream @@ -140,6 +140,7 @@ #include #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header Index: include/string =================================================================== --- include/string +++ include/string @@ -4170,11 +4170,13 @@ __lhs.swap(__rhs); } +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) +typedef basic_string u8string; +#endif + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - typedef basic_string u16string; typedef basic_string u32string; - #endif // _LIBCPP_HAS_NO_UNICODE_CHARS _LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10); @@ -4331,7 +4333,15 @@ return basic_string (__str, __len); } +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) inline _LIBCPP_INLINE_VISIBILITY + basic_string operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT + { + return basic_string (__str, __len); + } +#endif + + inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s( const char16_t *__str, size_t __len ) { return basic_string (__str, __len); Index: include/string_view =================================================================== --- include/string_view +++ include/string_view @@ -769,6 +769,9 @@ } typedef basic_string_view string_view; +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) +typedef basic_string_view u8string_view; +#endif typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; typedef basic_string_view wstring_view; @@ -802,7 +805,15 @@ return basic_string_view (__str, __len); } +#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t) inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + basic_string_view operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT + { + return basic_string_view (__str, __len); + } +#endif + + inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); Index: include/version =================================================================== --- include/version +++ include/version @@ -30,6 +30,8 @@ __cpp_lib_bool_constant 201505L __cpp_lib_boyer_moore_searcher 201603L __cpp_lib_byte 201603L +__cpp_lib_char8_t 201811L + __cpp_lib_chrono 201611L __cpp_lib_chrono_udls 201304L __cpp_lib_clamp 201603L @@ -114,6 +116,9 @@ #endif #if _LIBCPP_STD_VER > 17 +#ifdef __cpp_char8_t +# define __cpp_lib_char8_t 201811L #endif +#endif #endif // _LIBCPP_VERSIONH Index: test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/any.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/any.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/any.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp @@ -11,6 +11,7 @@ // feature macros /* Constant Value + __cpp_lib_char8_t 201811L __cpp_lib_atomic_is_always_lock_free 201603L __cpp_lib_atomic_ref 201806L @@ -19,6 +20,7 @@ // UNSUPPORTED: libcpp-has-no-threads #include +#include #include "test_macros.h" int main() @@ -25,7 +27,16 @@ { // ensure that the macros that are supposed to be defined in are defined. -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_atomic_is_always_lock_free) # error "__cpp_lib_atomic_is_always_lock_free is not defined" # elif __cpp_lib_atomic_is_always_lock_free < 201603L Index: test/std/language.support/support.limits/support.limits.general/bit.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/bit.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/bit.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/cmath.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/cmath.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/cmath.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/concepts.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/concepts.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/concepts.version.pass.cpp @@ -17,6 +17,7 @@ // XFAIL // #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/cstddef.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/cstddef.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/cstddef.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/deque.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/deque.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/deque.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/exception.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/exception.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/exception.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/execution.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/execution.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/execution.version.pass.cpp @@ -17,6 +17,7 @@ // XFAIL // #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp @@ -11,11 +11,13 @@ // feature macros /* Constant Value + __cpp_lib_char8_t 201811L __cpp_lib_filesystem 201703L */ #include +#include #include "test_macros.h" int main() @@ -22,7 +24,16 @@ { // ensure that the macros that are supposed to be defined in are defined. -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_filesystem) # error "__cpp_lib_filesystem is not defined" # elif __cpp_lib_filesystem < 201703L Index: test/std/language.support/support.limits/support.limits.general/forward_list.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/forward_list.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/forward_list.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "test_macros.h" int main() @@ -26,7 +27,7 @@ { // ensure that the macros that are supposed to be defined in are defined. -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_invoke) # error "__cpp_lib_invoke is not defined" # elif __cpp_lib_invoke < 201411L Index: test/std/language.support/support.limits/support.limits.general/iomanip.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/iomanip.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/iomanip.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp @@ -0,0 +1,42 @@ + +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// feature macros + +/* Constant Value + __cpp_lib_char8_t 201811L + +*/ + +#include +#include +#include "test_macros.h" + +int main() +{ +// ensure that the macros that are supposed to be defined in are defined. + +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +/* +#if !defined(__cpp_lib_fooby) +# error "__cpp_lib_fooby is not defined" +#elif __cpp_lib_fooby < 201606L +# error "__cpp_lib_fooby has an invalid value" +#endif +*/ +} Index: test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp @@ -0,0 +1,42 @@ + +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// feature macros + +/* Constant Value + __cpp_lib_char8_t 201811L + +*/ + +#include +#include +#include "test_macros.h" + +int main() +{ +// ensure that the macros that are supposed to be defined in are defined. + +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +/* +#if !defined(__cpp_lib_fooby) +# error "__cpp_lib_fooby is not defined" +#elif __cpp_lib_fooby < 201606L +# error "__cpp_lib_fooby has an invalid value" +#endif +*/ +} Index: test/std/language.support/support.limits/support.limits.general/list.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/list.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/list.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp @@ -0,0 +1,42 @@ + +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// feature macros + +/* Constant Value + __cpp_lib_char8_t 201811L + +*/ + +#include +#include +#include "test_macros.h" + +int main() +{ +// ensure that the macros that are supposed to be defined in are defined. + +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +/* +#if !defined(__cpp_lib_fooby) +# error "__cpp_lib_fooby is not defined" +#elif __cpp_lib_fooby < 201606L +# error "__cpp_lib_fooby has an invalid value" +#endif +*/ +} Index: test/std/language.support/support.limits/support.limits.general/map.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/map.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/map.version.pass.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp @@ -23,6 +23,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp @@ -17,6 +17,7 @@ // XFAIL // #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/optional.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/optional.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/optional.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp @@ -0,0 +1,42 @@ + +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// feature macros + +/* Constant Value + __cpp_lib_char8_t 201811L + +*/ + +#include +#include +#include "test_macros.h" + +int main() +{ +// ensure that the macros that are supposed to be defined in are defined. + +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + +/* +#if !defined(__cpp_lib_fooby) +# error "__cpp_lib_fooby is not defined" +#elif __cpp_lib_fooby < 201606L +# error "__cpp_lib_fooby has an invalid value" +#endif +*/ +} Index: test/std/language.support/support.limits/support.limits.general/regex.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/regex.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/regex.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/scoped_allocator.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/scoped_allocator.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/scoped_allocator.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/set.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/set.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/set.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp @@ -19,6 +19,7 @@ // UNSUPPORTED: libcpp-has-no-threads #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/string.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/string.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/string.version.pass.cpp @@ -12,6 +12,7 @@ /* Constant Value __cpp_lib_allocator_traits_is_always_equal 201411L + __cpp_lib_char8_t 201811L __cpp_lib_nonmember_container_access 201411L __cpp_lib_string_udls 201304L __cpp_lib_string_view 201606L @@ -19,6 +20,7 @@ */ #include +#include #include "test_macros.h" int main() @@ -25,6 +27,15 @@ { // ensure that the macros that are supposed to be defined in are defined. +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + /* #if !defined(__cpp_lib_fooby) # error "__cpp_lib_fooby is not defined" Index: test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp @@ -11,11 +11,13 @@ // feature macros /* Constant Value + __cpp_lib_char8_t 201811L __cpp_lib_string_view 201606L */ #include +#include #include "test_macros.h" int main() @@ -22,6 +24,15 @@ { // ensure that the macros that are supposed to be defined in are defined. +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + /* #if !defined(__cpp_lib_fooby) # error "__cpp_lib_fooby is not defined" Index: test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp @@ -28,6 +28,7 @@ */ #include +#include #include "test_macros.h" int main() @@ -34,7 +35,7 @@ { // ensure that the macros that are supposed to be defined in are defined. -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_void_t) # error "__cpp_lib_void_t is not defined" # elif __cpp_lib_void_t < 201411L Index: test/std/language.support/support.limits/support.limits.general/unordered_map.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/unordered_map.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/unordered_map.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/unordered_set.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/unordered_set.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/unordered_set.version.pass.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/variant.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/variant.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/variant.version.pass.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/vector.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/vector.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/vector.version.pass.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "test_macros.h" int main() Index: test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp =================================================================== --- test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -88,6 +88,7 @@ */ #include +#include #include "test_macros.h" int main() @@ -94,7 +95,7 @@ { // ensure that the macros that are supposed to be defined in are defined. -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_atomic_is_always_lock_free) # error "__cpp_lib_atomic_is_always_lock_free is not defined" # elif __cpp_lib_atomic_is_always_lock_free < 201603L @@ -102,7 +103,7 @@ # endif #endif -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_filesystem) # error "__cpp_lib_filesystem is not defined" # elif __cpp_lib_filesystem < 201703L @@ -110,7 +111,7 @@ # endif #endif -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_invoke) # error "__cpp_lib_invoke is not defined" # elif __cpp_lib_invoke < 201411L @@ -118,7 +119,7 @@ # endif #endif -#if _TEST_STD_VER > 14 +#if TEST_STD_VER > 14 # if !defined(__cpp_lib_void_t) # error "__cpp_lib_void_t is not defined" # elif __cpp_lib_void_t < 201411L @@ -126,6 +127,15 @@ # endif #endif +#if TEST_STD_VER > 17 + LIBCPP_ASSERT(IS_DEFINED(__cpp_lib_char8_t)); // libc++ implements this +# if defined(__cpp_lib_char8_t) +# if __cpp_lib_char8_t < 201811L +# error "__cpp_lib_char8_t has an invalid value" +# endif +# endif +#endif + /* #if !defined(__cpp_lib_fooby) # error "__cpp_lib_fooby is not defined" Index: test/std/strings/basic.string.hash/enabled_hashes.pass.cpp =================================================================== --- test/std/strings/basic.string.hash/enabled_hashes.pass.cpp +++ test/std/strings/basic.string.hash/enabled_hashes.pass.cpp @@ -23,6 +23,9 @@ { test_hash_enabled_for_type(); test_hash_enabled_for_type(); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test_hash_enabled_for_type(); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS test_hash_enabled_for_type(); test_hash_enabled_for_type(); Index: test/std/strings/basic.string.hash/strings.pass.cpp =================================================================== --- test/std/strings/basic.string.hash/strings.pass.cpp +++ test/std/strings/basic.string.hash/strings.pass.cpp @@ -44,6 +44,9 @@ int main() { test(); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS test(); test(); Index: test/std/strings/basic.string.literals/literal.pass.cpp =================================================================== --- test/std/strings/basic.string.literals/literal.pass.cpp +++ test/std/strings/basic.string.literals/literal.pass.cpp @@ -15,15 +15,20 @@ #include "test_macros.h" +// This is changed by P0482 to return a std::u8string - re-enable when we implement that. +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string u8string; +#else + typedef std::string u8string; +#endif + + int main() { using namespace std::literals::string_literals; static_assert ( std::is_same::value, "" ); -// This is changed by P0482 to return a std::u8string -#if TEST_STD_VER <= 17 - static_assert ( std::is_same::value, "" ); -#endif + static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); @@ -30,33 +35,25 @@ std::string foo; std::wstring Lfoo; + u8string u8foo; std::u16string ufoo; std::u32string Ufoo; - foo = ""s; assert( foo.size() == 0); -// This is changed by P0482 to return a std::u8string -#if TEST_STD_VER <= 17 - foo = u8""s; assert( foo.size() == 0); -#endif - Lfoo = L""s; assert(Lfoo.size() == 0); - ufoo = u""s; assert(ufoo.size() == 0); - Ufoo = U""s; assert(Ufoo.size() == 0); + foo = ""s; assert( foo.size() == 0); + u8foo = u8""s; assert(u8foo.size() == 0); + Lfoo = L""s; assert( Lfoo.size() == 0); + ufoo = u""s; assert( ufoo.size() == 0); + Ufoo = U""s; assert( Ufoo.size() == 0); - foo = " "s; assert( foo.size() == 1); -// This is changed by P0482 to return a std::u8string -#if TEST_STD_VER <= 17 - foo = u8" "s; assert( foo.size() == 1); -#endif - Lfoo = L" "s; assert(Lfoo.size() == 1); - ufoo = u" "s; assert(ufoo.size() == 1); - Ufoo = U" "s; assert(Ufoo.size() == 1); + foo = " "s; assert( foo.size() == 1); + u8foo = u8" "s; assert(u8foo.size() == 1); + Lfoo = L" "s; assert( Lfoo.size() == 1); + ufoo = u" "s; assert( ufoo.size() == 1); + Ufoo = U" "s; assert( Ufoo.size() == 1); - foo = "ABC"s; assert( foo == "ABC"); assert( foo == std::string ( "ABC")); -// This is changed by P0482 to return a std::u8string -#if TEST_STD_VER <= 17 - foo = u8"ABC"s; assert( foo == u8"ABC"); assert( foo == std::string (u8"ABC")); -#endif - Lfoo = L"ABC"s; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring ( L"ABC")); - ufoo = u"ABC"s; assert(ufoo == u"ABC"); assert(ufoo == std::u16string( u"ABC")); - Ufoo = U"ABC"s; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string( U"ABC")); + foo = "ABC"s; assert( foo == "ABC"); assert( foo == std::string ( "ABC")); + u8foo = u8"ABC"s; assert(u8foo == u8"ABC"); assert(u8foo == u8string (u8"ABC")); + Lfoo = L"ABC"s; assert( Lfoo == L"ABC"); assert( Lfoo == std::wstring ( L"ABC")); + ufoo = u"ABC"s; assert( ufoo == u"ABC"); assert( ufoo == std::u16string( u"ABC")); + Ufoo = U"ABC"s; assert( Ufoo == U"ABC"); assert( Ufoo == std::u32string( U"ABC")); } Index: test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp =================================================================== --- test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp +++ test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp @@ -72,7 +72,19 @@ assert(s1.size() == sv.size()); assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0); } +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L { + std::u8string_view sv = u8"12345678901234"; + std::basic_string s1{sv, min_allocator{}}; + using S = decltype(s1); // what type did we get? + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v>, ""); + static_assert(std::is_same_v>, ""); + assert(s1.size() == sv.size()); + assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0); + } +#endif + { std::u16string_view sv = u"12345678901234"; std::basic_string s1{sv, min_allocator{}}; using S = decltype(s1); // what type did we get? Index: test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp =================================================================== --- test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp +++ test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp @@ -76,16 +76,18 @@ assert(s1.size() == 4); assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0); } +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L { - std::u16string_view sv = u"12345678901234"; - std::basic_string s1{sv, 0, 4, min_allocator{}}; + std::u8string_view sv = u8"12345678901234"; + std::basic_string s1{sv, 0, 4, min_allocator{}}; using S = decltype(s1); // what type did we get? - static_assert(std::is_same_v, ""); - static_assert(std::is_same_v>, ""); - static_assert(std::is_same_v>, ""); + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v>, ""); + static_assert(std::is_same_v>, ""); assert(s1.size() == 4); assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0); } +#endif { std::u32string_view sv = U"12345678901234"; std::basic_string s1{sv, 0, 4, explicit_allocator{}}; Index: test/std/strings/basic.string/string.iterators/iterators.pass.cpp =================================================================== --- test/std/strings/basic.string/string.iterators/iterators.pass.cpp +++ test/std/strings/basic.string/string.iterators/iterators.pass.cpp @@ -47,6 +47,20 @@ assert ( !(ii1 != cii )); } +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + { + typedef std::u8string C; + C::iterator ii1{}, ii2{}; + C::iterator ii4 = ii1; + C::const_iterator cii{}; + assert ( ii1 == ii2 ); + assert ( ii1 == ii4 ); + assert ( ii1 == cii ); + assert ( !(ii1 != ii2 )); + assert ( !(ii1 != cii )); + } +#endif + { // N3644 testing typedef std::u16string C; C::iterator ii1{}, ii2{}; Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 +// + +// template<> struct char_traits + +// static constexpr void assign(char_type& c1, const char_type& c2); + +#include +#include + +#include "test_macros.h" + +constexpr bool test_constexpr() +{ + char8_t c = u'1'; + std::char_traits::assign(c, u'a'); + return c == u'a'; +} + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + char8_t c = u8'\0'; + std::char_traits::assign(c, u8'a'); + assert(c == u8'a'); + + static_assert(test_constexpr(), ""); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include +#include + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + char8_t s2[3] = {0}; + assert(std::char_traits::assign(s2, 3, char8_t(5)) == s2); + assert(s2[0] == char8_t(5)); + assert(s2[1] == char8_t(5)); + assert(s2[2] == char8_t(5)); + assert(std::char_traits::assign(NULL, 0, char8_t(5)) == NULL); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr int compare(const char_type* s1, const char_type* s2, size_t n); + +#include +#include + +#include "test_macros.h" + +constexpr bool test_constexpr() +{ + return std::char_traits::compare(u8"123", u8"223", 3) < 0 + && std::char_traits::compare(u8"223", u8"123", 3) > 0 + && std::char_traits::compare(u8"123", u8"123", 3) == 0; +} + + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(std::char_traits::compare(u8"", u8"", 0) == 0); + assert(std::char_traits::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits::compare(u8"1", u8"1", 1) == 0); + assert(std::char_traits::compare(u8"1", u8"2", 1) < 0); + assert(std::char_traits::compare(u8"2", u8"1", 1) > 0); + + assert(std::char_traits::compare(u8"12", u8"12", 2) == 0); + assert(std::char_traits::compare(u8"12", u8"13", 2) < 0); + assert(std::char_traits::compare(u8"12", u8"22", 2) < 0); + assert(std::char_traits::compare(u8"13", u8"12", 2) > 0); + assert(std::char_traits::compare(u8"22", u8"12", 2) > 0); + + assert(std::char_traits::compare(u8"123", u8"123", 3) == 0); + assert(std::char_traits::compare(u8"123", u8"223", 3) < 0); + assert(std::char_traits::compare(u8"123", u8"133", 3) < 0); + assert(std::char_traits::compare(u8"123", u8"124", 3) < 0); + assert(std::char_traits::compare(u8"223", u8"123", 3) > 0); + assert(std::char_traits::compare(u8"133", u8"123", 3) > 0); + assert(std::char_traits::compare(u8"124", u8"123", 3) > 0); + + static_assert(test_constexpr(), "" ); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + char8_t s1[] = {1, 2, 3}; + char8_t s2[3] = {0}; + assert(std::char_traits::copy(s2, s1, 3) == s2); + assert(s2[0] == char8_t(1)); + assert(s2[1] == char8_t(2)); + assert(s2[2] == char8_t(3)); + assert(std::char_traits::copy(NULL, s1, 0) == NULL); + assert(std::char_traits::copy(s1, NULL, 0) == s1); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr int_type eof(); + +#include +#include + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + std::char_traits::int_type i = std::char_traits::eof(); + ((void)i); // Prevent unused warning +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr bool eq(char_type c1, char_type c2); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert( std::char_traits::eq(u8'a', u8'a')); + assert(!std::char_traits::eq(u8'a', u8'A')); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert( std::char_traits::eq_int_type(u8'a', u8'a')); + assert(!std::char_traits::eq_int_type(u8'a', u8'A')); + assert(!std::char_traits::eq_int_type(std::char_traits::eof(), u8'A')); + assert( std::char_traits::eq_int_type(std::char_traits::eof(), + std::char_traits::eof())); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include +#include + +#include "test_macros.h" + +constexpr bool test_constexpr() +{ + constexpr const char8_t *p = u8"123"; + return std::char_traits::find(p, 3, u8'1') == p + && std::char_traits::find(p, 3, u8'2') == p + 1 + && std::char_traits::find(p, 3, u8'3') == p + 2 + && std::char_traits::find(p, 3, u8'4') == nullptr; +} + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + char8_t s1[] = {1, 2, 3}; + assert(std::char_traits::find(s1, 3, char8_t(1)) == s1); + assert(std::char_traits::find(s1, 3, char8_t(2)) == s1+1); + assert(std::char_traits::find(s1, 3, char8_t(3)) == s1+2); + assert(std::char_traits::find(s1, 3, char8_t(4)) == 0); + assert(std::char_traits::find(s1, 3, char8_t(0)) == 0); + assert(std::char_traits::find(NULL, 0, char8_t(0)) == 0); + + static_assert(test_constexpr(), "" ); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr size_t length(const char_type* s); + +#include +#include + +#include "test_macros.h" + +constexpr bool test_constexpr() +{ + return std::char_traits::length(u8"") == 0 + && std::char_traits::length(u8"abcd") == 4; +} + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(std::char_traits::length(u8"") == 0); + assert(std::char_traits::length(u8"a") == 1); + assert(std::char_traits::length(u8"aa") == 2); + assert(std::char_traits::length(u8"aaa") == 3); + assert(std::char_traits::length(u8"aaaa") == 4); + + static_assert(test_constexpr(), ""); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr bool lt(char_type c1, char_type c2); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(!std::char_traits::lt(u8'a', u8'a')); + assert( std::char_traits::lt(u8'A', u8'a')); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + char8_t s1[] = {1, 2, 3}; + assert(std::char_traits::move(s1, s1+1, 2) == s1); + assert(s1[0] == char8_t(2)); + assert(s1[1] == char8_t(3)); + assert(s1[2] == char8_t(3)); + s1[2] = char8_t(0); + assert(std::char_traits::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char8_t(2)); + assert(s1[1] == char8_t(2)); + assert(s1[2] == char8_t(3)); + assert(std::char_traits::move(NULL, s1, 0) == NULL); + assert(std::char_traits::move(s1, NULL, 0) == s1); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr int_type not_eof(int_type c); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(std::char_traits::not_eof(u8'a') == u8'a'); + assert(std::char_traits::not_eof(u8'A') == u8'A'); + assert(std::char_traits::not_eof(0) == 0); + assert(std::char_traits::not_eof(std::char_traits::eof()) != + std::char_traits::eof()); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr char_type to_char_type(int_type c); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(std::char_traits::to_char_type(u8'a') == u8'a'); + assert(std::char_traits::to_char_type(u8'A') == u8'A'); + assert(std::char_traits::to_char_type(0) == 0); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// static constexpr int_type to_int_type(char_type c); + +#include +#include + +#include "test_macros.h" + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert(std::char_traits::to_int_type(u8'a') == u8'a'); + assert(std::char_traits::to_int_type(u8'A') == u8'A'); + assert(std::char_traits::to_int_type(0) == 0); +#endif +} Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp =================================================================== --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// + +// template<> struct char_traits + +// typedef char8_t char_type; +// typedef unsigned int int_type; +// typedef streamoff off_type; +// typedef u16streampos pos_type; +// typedef mbstate_t state_type; + +#include +#include +#include + +int main() +{ +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + 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::state_type, std::mbstate_t>::value), ""); +#endif +} Index: test/std/strings/string.classes/typedefs.pass.cpp =================================================================== --- test/std/strings/string.classes/typedefs.pass.cpp +++ test/std/strings/string.classes/typedefs.pass.cpp @@ -12,18 +12,24 @@ // Test for the existence of: // basic_string typedef names -// typedef basic_string string; +// typedef basic_string string; // typedef basic_string u16string; +// typedef basic_string u8string; // C++20 // typedef basic_string u32string; -// typedef basic_string wstring; +// typedef basic_string wstring; #include #include +#include "test_macros.h" + int main() { static_assert((std::is_same >::value), ""); static_assert((std::is_same >::value), ""); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert((std::is_same >::value), ""); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS static_assert((std::is_same >::value), ""); static_assert((std::is_same >::value), ""); Index: test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp +++ test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp @@ -23,6 +23,9 @@ { test_hash_enabled_for_type(); test_hash_enabled_for_type(); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test_hash_enabled_for_type(); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS test_hash_enabled_for_type(); test_hash_enabled_for_type(); Index: test/std/strings/string.view/string.view.hash/string_view.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.hash/string_view.pass.cpp +++ test/std/strings/string.view/string.view.hash/string_view.pass.cpp @@ -59,6 +59,9 @@ int main() { test(); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS test(); test(); Index: test/std/strings/string.view/string.view.capacity/capacity.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.capacity/capacity.pass.cpp +++ test/std/strings/string.view/string.view.capacity/capacity.pass.cpp @@ -64,16 +64,14 @@ } int main () { - typedef std::string_view string_view; - typedef std::u16string_view u16string_view; - typedef std::u32string_view u32string_view; - typedef std::wstring_view wstring_view; + test1 (); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test1 (); +#endif + test1 (); + test1 (); + test1 (); - test1 (); - test1 (); - test1 (); - test1 (); - test2 ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 ); test2 ( "ABCDE", 5 ); test2 ( "a", 1 ); @@ -84,6 +82,13 @@ test2 ( L"a", 1 ); test2 ( L"", 0 ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test2 ( u8"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 ); + test2 ( u8"ABCDE", 5 ); + test2 ( u8"a", 1 ); + test2 ( u8"", 0 ); +#endif + #if TEST_STD_VER >= 11 test2 ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 ); test2 ( u"ABCDE", 5 ); Index: test/std/strings/string.view/string.view.cons/assign.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.cons/assign.pass.cpp +++ test/std/strings/string.view/string.view.cons/assign.pass.cpp @@ -32,21 +32,27 @@ int main () { - assert( test ( "1234")); + assert( test ( "1234")); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + assert( test (u8"1234")); +#endif #if TEST_STD_VER >= 11 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - assert( test (u"1234")); - assert( test (U"1234")); + assert( test ( u"1234")); + assert( test ( U"1234")); #endif #endif - assert( test (L"1234")); + assert( test ( L"1234")); #if TEST_STD_VER > 11 - static_assert( test ({ "abc", 3}), ""); + static_assert( test ({ "abc", 3}), ""); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert( test ({u8"abc", 3}), ""); +#endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - static_assert( test ({u"abc", 3}), ""); - static_assert( test ({U"abc", 3}), ""); + static_assert( test ({ u"abc", 3}), ""); + static_assert( test ({ U"abc", 3}), ""); #endif - static_assert( test ({L"abc", 3}), ""); + static_assert( test ({ L"abc", 3}), ""); #endif } Index: test/std/strings/string.view/string.view.cons/default.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.cons/default.pass.cpp +++ test/std/strings/string.view/string.view.cons/default.pass.cpp @@ -37,14 +37,12 @@ } int main () { - typedef std::string_view string_view; - typedef std::u16string_view u16string_view; - typedef std::u32string_view u32string_view; - typedef std::wstring_view wstring_view; + test (); + test (); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test (); +#endif + test (); + test (); - test (); - test (); - test (); - test (); - } Index: test/std/strings/string.view/string.view.cons/from_string.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.cons/from_string.pass.cpp +++ test/std/strings/string.view/string.view.cons/from_string.pass.cpp @@ -42,6 +42,12 @@ test ( std::wstring(L"") ); test ( std::wstring() ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test ( std::u8string{u8"QBCDE"} ); + test ( std::u8string{u8""} ); + test ( std::u8string{} ); +#endif + #if TEST_STD_VER >= 11 test ( std::u16string{u"QBCDE"} ); test ( std::u16string{u""} ); Index: test/std/strings/string.view/string.view.iterators/begin.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.iterators/begin.pass.cpp +++ test/std/strings/string.view/string.view.iterators/begin.pass.cpp @@ -43,6 +43,9 @@ int main() { typedef std::string_view string_view; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string_view u8string_view; +#endif typedef std::u16string_view u16string_view; typedef std::u32string_view u32string_view; typedef std::wstring_view wstring_view; @@ -53,6 +56,9 @@ test(wstring_view ()); test(string_view ( "123")); test(wstring_view (L"123")); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(u8string_view{u8"123"}); +#endif #if TEST_STD_VER >= 11 test(u16string_view{u"123"}); test(u32string_view{U"123"}); @@ -61,16 +67,25 @@ #if TEST_STD_VER > 11 { constexpr string_view sv { "123", 3 }; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + constexpr u8string_view u8sv {u8"123", 3 }; +#endif constexpr u16string_view u16sv {u"123", 3 }; constexpr u32string_view u32sv {U"123", 3 }; constexpr wstring_view wsv {L"123", 3 }; static_assert ( *sv.begin() == sv[0], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *u8sv.begin() == u8sv[0], "" ); +#endif static_assert ( *u16sv.begin() == u16sv[0], "" ); static_assert ( *u32sv.begin() == u32sv[0], "" ); static_assert ( *wsv.begin() == wsv[0], "" ); static_assert ( *sv.cbegin() == sv[0], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *u8sv.cbegin() == u8sv[0], "" ); +#endif static_assert ( *u16sv.cbegin() == u16sv[0], "" ); static_assert ( *u32sv.cbegin() == u32sv[0], "" ); static_assert ( *wsv.cbegin() == wsv[0], "" ); Index: test/std/strings/string.view/string.view.iterators/end.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.iterators/end.pass.cpp +++ test/std/strings/string.view/string.view.iterators/end.pass.cpp @@ -52,6 +52,9 @@ int main() { typedef std::string_view string_view; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string_view u8string_view; +#endif typedef std::u16string_view u16string_view; typedef std::u32string_view u32string_view; typedef std::wstring_view wstring_view; @@ -62,6 +65,9 @@ test(wstring_view ()); test(string_view ( "123")); test(wstring_view (L"123")); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(u8string_view{u8"123"}); +#endif #if TEST_STD_VER >= 11 test(u16string_view{u"123"}); test(u32string_view{U"123"}); @@ -70,16 +76,25 @@ #if TEST_STD_VER > 11 { constexpr string_view sv { "123", 3 }; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + constexpr u8string_view u8sv {u8"123", 3 }; +#endif constexpr u16string_view u16sv {u"123", 3 }; constexpr u32string_view u32sv {U"123", 3 }; constexpr wstring_view wsv {L"123", 3 }; static_assert ( sv.begin() != sv.end(), "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( u8sv.begin() != u8sv.end(), "" ); +#endif static_assert ( u16sv.begin() != u16sv.end(), "" ); static_assert ( u32sv.begin() != u32sv.end(), "" ); static_assert ( wsv.begin() != wsv.end(), "" ); static_assert ( sv.begin() != sv.cend(), "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( u8sv.begin() != u8sv.cend(), "" ); +#endif static_assert ( u16sv.begin() != u16sv.cend(), "" ); static_assert ( u32sv.begin() != u32sv.cend(), "" ); static_assert ( wsv.begin() != wsv.cend(), "" ); Index: test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp +++ test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp @@ -44,6 +44,9 @@ int main() { typedef std::string_view string_view; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string_view u8string_view; +#endif typedef std::u16string_view u16string_view; typedef std::u32string_view u32string_view; typedef std::wstring_view wstring_view; @@ -54,6 +57,9 @@ test(wstring_view ()); test(string_view ( "123")); test(wstring_view (L"123")); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(u8string_view{u8"123"}); +#endif #if TEST_STD_VER >= 11 test(u16string_view{u"123"}); test(u32string_view{U"123"}); @@ -62,16 +68,25 @@ #if TEST_STD_VER > 14 { constexpr string_view sv { "123", 3 }; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + constexpr u8string_view u8sv {u8"123", 3 }; +#endif constexpr u16string_view u16sv {u"123", 3 }; constexpr u32string_view u32sv {U"123", 3 }; constexpr wstring_view wsv {L"123", 3 }; static_assert ( *sv.rbegin() == sv[2], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *u8sv.rbegin() == u8sv[2], "" ); +#endif static_assert ( *u16sv.rbegin() == u16sv[2], "" ); static_assert ( *u32sv.rbegin() == u32sv[2], "" ); static_assert ( *wsv.rbegin() == wsv[2], "" ); static_assert ( *sv.crbegin() == sv[2], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *u8sv.crbegin() == u8sv[2], "" ); +#endif static_assert ( *u16sv.crbegin() == u16sv[2], "" ); static_assert ( *u32sv.crbegin() == u32sv[2], "" ); static_assert ( *wsv.crbegin() == wsv[2], "" ); Index: test/std/strings/string.view/string.view.iterators/rend.pass.cpp =================================================================== --- test/std/strings/string.view/string.view.iterators/rend.pass.cpp +++ test/std/strings/string.view/string.view.iterators/rend.pass.cpp @@ -52,6 +52,9 @@ int main() { typedef std::string_view string_view; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string_view u8string_view; +#endif typedef std::u16string_view u16string_view; typedef std::u32string_view u32string_view; typedef std::wstring_view wstring_view; @@ -62,6 +65,9 @@ test(wstring_view ()); test(string_view ( "123")); test(wstring_view (L"123")); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test(u8string_view{u8"123"}); +#endif #if TEST_STD_VER >= 11 test(u16string_view{u"123"}); test(u32string_view{U"123"}); @@ -70,16 +76,25 @@ #if TEST_STD_VER > 14 { constexpr string_view sv { "123", 3 }; +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + constexpr u8string_view u8sv {u8"123", 3 }; +#endif constexpr u16string_view u16sv {u"123", 3 }; constexpr u32string_view u32sv {U"123", 3 }; constexpr wstring_view wsv {L"123", 3 }; static_assert ( *--sv.rend() == sv[0], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *--u8sv.rend() == u8sv[0], "" ); +#endif static_assert ( *--u16sv.rend() == u16sv[0], "" ); static_assert ( *--u32sv.rend() == u32sv[0], "" ); static_assert ( *--wsv.rend() == wsv[0], "" ); static_assert ( *--sv.crend() == sv[0], "" ); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + static_assert ( *--u8sv.crend() == u8sv[0], "" ); +#endif static_assert ( *--u16sv.crend() == u16sv[0], "" ); static_assert ( *--u32sv.crend() == u32sv[0], "" ); static_assert ( *--wsv.crend() == wsv[0], "" ); Index: test/std/strings/string.view/string_view.literals/literal.pass.cpp =================================================================== --- test/std/strings/string.view/string_view.literals/literal.pass.cpp +++ test/std/strings/string.view/string_view.literals/literal.pass.cpp @@ -18,15 +18,19 @@ #include "test_macros.h" +// This is changed by P0482 to return a std::u8string - re-enable when we implement that. +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + typedef std::u8string_view u8string_view; +#else + typedef std::string_view u8string_view; +#endif + int main() { using namespace std::literals::string_view_literals; static_assert ( std::is_same::value, "" ); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 - static_assert ( std::is_same::value, "" ); -#endif + static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); static_assert ( std::is_same::value, "" ); @@ -33,50 +37,37 @@ std::string_view foo; std::wstring_view Lfoo; + u8string_view u8foo; std::u16string_view ufoo; std::u32string_view Ufoo; - foo = ""sv; assert( foo.size() == 0); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 - foo = u8""sv; assert( foo.size() == 0); -#endif - Lfoo = L""sv; assert(Lfoo.size() == 0); - ufoo = u""sv; assert(ufoo.size() == 0); - Ufoo = U""sv; assert(Ufoo.size() == 0); + + foo = ""sv; assert( foo.size() == 0); + u8foo = u8""sv; assert(u8foo.size() == 0); + Lfoo = L""sv; assert( Lfoo.size() == 0); + ufoo = u""sv; assert( ufoo.size() == 0); + Ufoo = U""sv; assert( Ufoo.size() == 0); - foo = " "sv; assert( foo.size() == 1); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 - foo = u8" "sv; assert( foo.size() == 1); -#endif - Lfoo = L" "sv; assert(Lfoo.size() == 1); - ufoo = u" "sv; assert(ufoo.size() == 1); - Ufoo = U" "sv; assert(Ufoo.size() == 1); + foo = " "sv; assert( foo.size() == 1); + u8foo = u8" "sv; assert(u8foo.size() == 1); + Lfoo = L" "sv; assert( Lfoo.size() == 1); + ufoo = u" "sv; assert( ufoo.size() == 1); + Ufoo = U" "sv; assert( Ufoo.size() == 1); - foo = "ABC"sv; assert( foo == "ABC"); assert( foo == std::string_view ( "ABC")); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 - foo = u8"ABC"sv; assert( foo == u8"ABC"); assert( foo == std::string_view (u8"ABC")); -#endif - Lfoo = L"ABC"sv; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring_view ( L"ABC")); - ufoo = u"ABC"sv; assert(ufoo == u"ABC"); assert(ufoo == std::u16string_view( u"ABC")); - Ufoo = U"ABC"sv; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string_view( U"ABC")); + foo = "ABC"sv; assert( foo == "ABC"); assert( foo == std::string_view ( "ABC")); + u8foo = u8"ABC"sv; assert(u8foo == u8"ABC"); assert(u8foo == u8string_view (u8"ABC")); + Lfoo = L"ABC"sv; assert( Lfoo == L"ABC"); assert( Lfoo == std::wstring_view ( L"ABC")); + ufoo = u"ABC"sv; assert( ufoo == u"ABC"); assert( ufoo == std::u16string_view( u"ABC")); + Ufoo = U"ABC"sv; assert( Ufoo == U"ABC"); assert( Ufoo == std::u32string_view( U"ABC")); static_assert( "ABC"sv.size() == 3, ""); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 static_assert(u8"ABC"sv.size() == 3, ""); -#endif static_assert( L"ABC"sv.size() == 3, ""); static_assert( u"ABC"sv.size() == 3, ""); static_assert( U"ABC"sv.size() == 3, ""); static_assert(noexcept( "ABC"sv), ""); -// This is changed by P0482 to return a std::u8string - re-enable when we implement that. -#if TEST_STD_VER <= 17 static_assert(noexcept(u8"ABC"sv), ""); -#endif static_assert(noexcept( L"ABC"sv), ""); static_assert(noexcept( u"ABC"sv), ""); static_assert(noexcept( U"ABC"sv), ""); Index: test/std/strings/string.view/types.pass.cpp =================================================================== --- test/std/strings/string.view/types.pass.cpp +++ test/std/strings/string.view/types.pass.cpp @@ -72,6 +72,9 @@ { test >(); test >(); +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L + test >(); +#endif static_assert((std::is_same::traits_type, std::char_traits >::value), ""); } Index: test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp =================================================================== --- test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp +++ test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp @@ -85,7 +85,7 @@ test_is_integral(); test_is_integral(); test_is_integral(); -#if TEST_STD_VER > 17 && defined(__cpp_char8_t) +#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L test_is_integral(); #endif Index: test/support/test_macros.h =================================================================== --- test/support/test_macros.h +++ test/support/test_macros.h @@ -212,6 +212,13 @@ // implementation, or (b) a feature check macro is specified #define TEST_HAS_NO_SPACESHIP_OPERATOR +// Checking for a Macro being defined +// test if the name of the macro is different from the text +// will not work for #define FOO FOO +// Cribbed from https://stackoverflow.com/questions/26099745/test-if-preprocessor-symbol-is-defined-inside-macro +extern "C" int strcmp(const char *, const char *); // so we don't have to include here +#define STRINGIFY(item) "" #item +#define IS_DEFINED(macro) (strcmp("" #macro, STRINGIFY(macro))) #if TEST_STD_VER < 11 #define ASSERT_NOEXCEPT(...)