Second part of P0482 - char8_t. Reviewed as https://reviews.llvm.org/D55308
authorMarshall Clow <mclow.lists@gmail.com>
Tue, 11 Dec 2018 04:35:44 +0000 (04:35 +0000)
committerMarshall Clow <mclow.lists@gmail.com>
Tue, 11 Dec 2018 04:35:44 +0000 (04:35 +0000)
llvm-svn: 348828

91 files changed:
libcxx/include/__config
libcxx/include/__string
libcxx/include/iosfwd
libcxx/include/istream
libcxx/include/limits
libcxx/include/locale
libcxx/include/ostream
libcxx/include/string
libcxx/include/string_view
libcxx/include/type_traits
libcxx/include/version
libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/any.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/bit.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/cmath.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/concepts.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/cstddef.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/exception.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/execution.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/iomanip.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp [new file with mode: 0644]
libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp [new file with mode: 0644]
libcxx/test/std/language.support/support.limits/support.limits.general/list.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp [new file with mode: 0644]
libcxx/test/std/language.support/support.limits/support.limits.general/map.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp [new file with mode: 0644]
libcxx/test/std/language.support/support.limits/support.limits.general/regex.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/scoped_allocator.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/set.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/string.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/unordered_map.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/unordered_set.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/vector.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp
libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
libcxx/test/std/strings/basic.string.literals/literal.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/types.pass.cpp [new file with mode: 0644]
libcxx/test/std/strings/string.classes/typedefs.pass.cpp
libcxx/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp
libcxx/test/std/strings/string.view/string.view.cons/assign.pass.cpp
libcxx/test/std/strings/string.view/string.view.cons/default.pass.cpp
libcxx/test/std/strings/string.view/string.view.cons/from_string.pass.cpp
libcxx/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp
libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp
libcxx/test/std/strings/string.view/string.view.iterators/begin.pass.cpp
libcxx/test/std/strings/string.view/string.view.iterators/end.pass.cpp
libcxx/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp
libcxx/test/std/strings/string.view/string.view.iterators/rend.pass.cpp
libcxx/test/std/strings/string.view/string_view.literals/literal.pass.cpp
libcxx/test/std/strings/string.view/types.pass.cpp
libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp

index b4367d0..88c207c 100644 (file)
@@ -1004,6 +1004,10 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_WCTYPE_IS_MASK
 #endif
 
+#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
+#define _LIBCPP_NO_HAS_CHAR8_T
+#endif
+
 // Deprecation macros.
 // Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined.
 #if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS)
index 44c5598..1ddeec7 100644 (file)
@@ -47,6 +47,7 @@ struct char_traits
 
 template <> struct char_traits<char>;
 template <> struct char_traits<wchar_t>;
+template <> struct char_traits<char8_t>;  // c++20
 
 }  // std
 
@@ -389,6 +390,102 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
 }
 
 
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
+{
+    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<char8_t>::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<char8_t>::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<char8_t>::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_NO_HAS_CHAR8_T
+
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
 
 template <>
index d438485..31f1902 100644 (file)
@@ -18,6 +18,12 @@ namespace std
 {
 
 template<class charT> struct char_traits;
+template<>            struct char_traits<char>;
+template<>            struct char_traits<char8_t>;  // C++20
+template<>            struct char_traits<char16_t>;
+template<>            struct char_traits<char32_t>;
+template<>            struct char_traits<wchar_t>;
+
 template<class T>     class allocator;
 
 class ios_base;
@@ -98,6 +104,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 class _LIBCPP_TYPE_VIS ios_base;
 
 template<class _CharT>  struct _LIBCPP_TEMPLATE_VIS char_traits;
+template<> struct char_traits<char>;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template<> struct char_traits<char8_t>;
+#endif
+template<> struct char_traits<char16_t>;
+template<> struct char_traits<char32_t>;
+template<> struct char_traits<wchar_t>;
+
 template<class _Tp>     class _LIBCPP_TEMPLATE_VIS allocator;
 
 template <class _CharT, class _Traits = char_traits<_CharT> >
@@ -175,6 +189,9 @@ typedef basic_fstream<wchar_t>       wfstream;
 template <class _State>             class _LIBCPP_TEMPLATE_VIS fpos;
 typedef fpos<mbstate_t>    streampos;
 typedef fpos<mbstate_t>    wstreampos;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef fpos<mbstate_t>    u8streampos;
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef fpos<mbstate_t>    u16streampos;
 typedef fpos<mbstate_t>    u32streampos;
index efbbae8..30ee4f4 100644 (file)
@@ -160,6 +160,7 @@ template <class charT, class traits, class T>
 */
 
 #include <__config>
+#include <version>
 #include <ostream>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
index 5b75f4a..5ea9a9e 100644 (file)
@@ -119,6 +119,7 @@ template<> class numeric_limits<cv long double>;
 
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
+#include <version>
 
 
 _LIBCPP_BEGIN_NAMESPACE_STD
index 3a8dfbc..ac589d3 100644 (file)
@@ -187,6 +187,7 @@ template <class charT> class messages_byname;
 #include <streambuf>
 #include <iterator>
 #include <limits>
+#include <version>
 #ifndef __APPLE__
 #include <cstdarg>
 #endif
index d7a5d52..d700a36 100644 (file)
@@ -140,6 +140,7 @@ template <class charT, class traits, class T>
 #include <locale>
 #include <iterator>
 #include <bitset>
+#include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
index 31ad307..4dd6ddc 100644 (file)
@@ -4170,11 +4170,13 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
     __lhs.swap(__rhs);
 }
 
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string<char8_t> u8string;
+#endif
 
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef basic_string<char16_t> u16string;
 typedef basic_string<char32_t> u32string;
-
 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
 
 _LIBCPP_FUNC_VIS int                stoi  (const string& __str, size_t* __idx = 0, int __base = 10);
@@ -4331,6 +4333,14 @@ inline namespace literals
         return basic_string<wchar_t> (__str, __len);
     }
 
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+    inline _LIBCPP_INLINE_VISIBILITY
+    basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
+    {
+        return basic_string<char8_t> (__str, __len);
+    }
+#endif
+
     inline _LIBCPP_INLINE_VISIBILITY
     basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
     {
index dd425a2..7d78312 100644 (file)
@@ -769,6 +769,9 @@ bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type
 }
 
 typedef basic_string_view<char>     string_view;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string_view<char8_t>  u8string_view;
+#endif
 typedef basic_string_view<char16_t> u16string_view;
 typedef basic_string_view<char32_t> u32string_view;
 typedef basic_string_view<wchar_t>  wstring_view;
@@ -802,6 +805,14 @@ inline namespace literals
         return basic_string_view<wchar_t> (__str, __len);
     }
 
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT
+    {
+        return basic_string_view<char8_t> (__str, __len);
+    }
+#endif
+
     inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
     basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
     {
index 09c0019..ab01071 100644 (file)
@@ -709,7 +709,7 @@ template <>          struct __libcpp_is_integral<char>               : public tr
 template <>          struct __libcpp_is_integral<signed char>        : public true_type {};
 template <>          struct __libcpp_is_integral<unsigned char>      : public true_type {};
 template <>          struct __libcpp_is_integral<wchar_t>            : public true_type {};
-#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t)
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
 template <>          struct __libcpp_is_integral<char8_t>            : public true_type {};
 #endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
index aca84f8..5e758fc 100644 (file)
@@ -30,6 +30,8 @@ __cpp_lib_bit_cast                          201806L <bit>
 __cpp_lib_bool_constant                     201505L <type_traits>
 __cpp_lib_boyer_moore_searcher              201603L <functional>
 __cpp_lib_byte                              201603L <cstddef>
+__cpp_lib_char8_t                           201811L <atomic> <filesystem> <istream> <limits>
+                                                    <locale> <ostream> <string> <string_view>
 __cpp_lib_chrono                            201611L <chrono>
 __cpp_lib_chrono_udls                       201304L <chrono>
 __cpp_lib_clamp                             201603L <algorithm>
@@ -114,6 +116,9 @@ __cpp_lib_void_t                            201411L <type_traits>
 #endif
 
 #if _LIBCPP_STD_VER > 17
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+# define __cpp_lib_char8_t                              201811L
+#endif
 #endif
 
 #endif  // _LIBCPP_VERSIONH
index 0c15dc5..a990cab 100644 (file)
@@ -11,6 +11,7 @@
 // <atomic> feature macros
 
 /*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
     __cpp_lib_atomic_is_always_lock_free        201603L
     __cpp_lib_atomic_ref                        201806L
 
 // UNSUPPORTED: libcpp-has-no-threads
 
 #include <atomic>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <atomic> are defined.
 
-#if _TEST_STD_VER > 14
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 46ad17d..160a997 100644 (file)
 // <filesystem> feature macros
 
 /*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
     __cpp_lib_filesystem                        201703L
 
 */
 
 #include <filesystem>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <filesystem> are defined.
 
-#if _TEST_STD_VER > 14
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 a24de49..57978cb 100644 (file)
 */
 
 #include <functional>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <functional> 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
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp
new file mode 100644 (file)
index 0000000..dfa0052
--- /dev/null
@@ -0,0 +1,43 @@
+
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// <istream> feature macros
+
+/*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
+
+*/
+
+#include <istream>
+#include <cassert>
+#include "test_macros.h"
+
+int main()
+{
+//  ensure that the macros that are supposed to be defined in <istream> are defined.
+
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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
+*/
+}
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/limits.version.pass.cpp
new file mode 100644 (file)
index 0000000..5d49971
--- /dev/null
@@ -0,0 +1,43 @@
+
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// <limits> feature macros
+
+/*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
+
+*/
+
+#include <limits>
+#include <cassert>
+#include "test_macros.h"
+
+int main()
+{
+//  ensure that the macros that are supposed to be defined in <limits> are defined.
+
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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
+*/
+}
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp
new file mode 100644 (file)
index 0000000..4c45c0a
--- /dev/null
@@ -0,0 +1,43 @@
+
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// <locale> feature macros
+
+/*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
+
+*/
+
+#include <locale>
+#include <cassert>
+#include "test_macros.h"
+
+int main()
+{
+//  ensure that the macros that are supposed to be defined in <locale> are defined.
+
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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
+*/
+}
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp
new file mode 100644 (file)
index 0000000..5f2ffb2
--- /dev/null
@@ -0,0 +1,43 @@
+
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// <ostream> feature macros
+
+/*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
+
+*/
+
+#include <ostream>
+#include <cassert>
+#include "test_macros.h"
+
+int main()
+{
+//  ensure that the macros that are supposed to be defined in <ostream> are defined.
+
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 2b755b6..02aa15c 100644 (file)
@@ -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
 */
 
 #include <string>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <string> are defined.
 
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 53e7682..82f1c66 100644 (file)
 // <string_view> feature macros
 
 /*  Constant                                    Value
+    __cpp_lib_char8_t                           201811L
     __cpp_lib_string_view                       201606L
 
 */
 
 #include <string_view>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <string_view> are defined.
 
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 9f7eced..e53da7e 100644 (file)
 */
 
 #include <type_traits>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <type_traits> 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 e52c188..f4be2eb 100644 (file)
 */
 
 #include <version>
+#include <cassert>
 #include "test_macros.h"
 
 int main()
 {
 //  ensure that the macros that are supposed to be defined in <version> 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 @@ int main()
 # 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 @@ int main()
 # 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 @@ int main()
 # 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,16 @@ int main()
 # endif
 #endif
 
+#if TEST_STD_VER > 17
+# if !defined(__cpp_lib_char8_t)  
+  LIBCPP_STATIC_ASSERT(false, "__cpp_lib_char8_t is not defined");
+# else
+#  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 01f0121..e6f3d53 100644 (file)
@@ -23,6 +23,9 @@ int main() {
   {
     test_hash_enabled_for_type<std::string>();
     test_hash_enabled_for_type<std::wstring>();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test_hash_enabled_for_type<std::u8string>();
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     test_hash_enabled_for_type<std::u16string>();
     test_hash_enabled_for_type<std::u32string>();
index d74e485..449ad8f 100644 (file)
@@ -44,6 +44,9 @@ test()
 int main()
 {
     test<std::string>();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test<std::u8string>();
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     test<std::u16string>();
     test<std::u32string>();
index 65ebb3c..cbb03ef 100644 (file)
 
 #include "test_macros.h"
 
+#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<decltype(   "Hi"s), std::string>::value, "" );
-//     This is changed by P0482 to return a std::u8string
-#if TEST_STD_VER <= 17
-    static_assert ( std::is_same<decltype( u8"Hi"s), std::string>::value, "" );
-#endif
+    static_assert ( std::is_same<decltype( u8"Hi"s), u8string>::value, "" );
     static_assert ( std::is_same<decltype(  L"Hi"s), std::wstring>::value, "" );
     static_assert ( std::is_same<decltype(  u"Hi"s), std::u16string>::value, "" );
     static_assert ( std::is_same<decltype(  U"Hi"s), std::u32string>::value, "" );
 
     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() == 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  =   "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   =   ""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);
+    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"));
+    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 df1e99e..a1f3c4b 100644 (file)
@@ -72,6 +72,18 @@ int main()
     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<char8_t>{}};
+    using S = decltype(s1); // what type did we get?
+    static_assert(std::is_same_v<S::value_type,                      char8_t>,  "");
+    static_assert(std::is_same_v<S::traits_type,    std::char_traits<char8_t>>, "");
+    static_assert(std::is_same_v<S::allocator_type,    min_allocator<char8_t>>, "");
+    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<char16_t>{}};
index 22ca2fd..fd9684e 100644 (file)
@@ -76,6 +76,18 @@ int main()
     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::u8string_view sv = u8"12345678901234";
+    std::basic_string s1{sv, 0, 4, min_allocator<char8_t>{}};
+    using S = decltype(s1); // what type did we get?
+    static_assert(std::is_same_v<S::value_type,                      char8_t>,  "");
+    static_assert(std::is_same_v<S::traits_type,    std::char_traits<char8_t>>, "");
+    static_assert(std::is_same_v<S::allocator_type,    min_allocator<char8_t>>, "");
+    assert(s1.size() == 4);
+    assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
+    }
+#endif
     {
     std::u16string_view sv = u"12345678901234";
     std::basic_string s1{sv, 0, 4, min_allocator<char16_t>{}};
index 9466f11..8bc6e4f 100644 (file)
@@ -47,6 +47,20 @@ int main()
         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{};
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp
new file mode 100644 (file)
index 0000000..e293115
--- /dev/null
@@ -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
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+constexpr bool test_constexpr()
+{
+    char8_t c = u'1';
+    std::char_traits<char8_t>::assign(c, u'a');
+    return c == u'a';
+}
+
+int main()
+{
+    char8_t c = u8'\0';
+    std::char_traits<char8_t>::assign(c, u8'a');
+    assert(c == u8'a');
+
+    static_assert(test_constexpr(), "");
+}
+#else
+int main () {}
+#endif
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign3.pass.cpp
new file mode 100644 (file)
index 0000000..d1fab48
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    char8_t s2[3] = {0};
+    assert(std::char_traits<char8_t>::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<char8_t>::assign(NULL, 0, char8_t(5)) == NULL);
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp
new file mode 100644 (file)
index 0000000..0ce036a
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool test_constexpr()
+{
+    return std::char_traits<char8_t>::compare(u8"123", u8"223", 3) < 0
+        && std::char_traits<char8_t>::compare(u8"223", u8"123", 3) > 0
+        && std::char_traits<char8_t>::compare(u8"123", u8"123", 3) == 0;
+}
+
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(std::char_traits<char8_t>::compare(u8"", u8"", 0) == 0);
+    assert(std::char_traits<char8_t>::compare(NULL, NULL, 0) == 0);
+
+    assert(std::char_traits<char8_t>::compare(u8"1", u8"1", 1) == 0);
+    assert(std::char_traits<char8_t>::compare(u8"1", u8"2", 1) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"2", u8"1", 1) > 0);
+
+    assert(std::char_traits<char8_t>::compare(u8"12", u8"12", 2) == 0);
+    assert(std::char_traits<char8_t>::compare(u8"12", u8"13", 2) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"12", u8"22", 2) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"13", u8"12", 2) > 0);
+    assert(std::char_traits<char8_t>::compare(u8"22", u8"12", 2) > 0);
+
+    assert(std::char_traits<char8_t>::compare(u8"123", u8"123", 3) == 0);
+    assert(std::char_traits<char8_t>::compare(u8"123", u8"223", 3) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"123", u8"133", 3) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"123", u8"124", 3) < 0);
+    assert(std::char_traits<char8_t>::compare(u8"223", u8"123", 3) > 0);
+    assert(std::char_traits<char8_t>::compare(u8"133", u8"123", 3) > 0);
+    assert(std::char_traits<char8_t>::compare(u8"124", u8"123", 3) > 0);
+
+    static_assert(test_constexpr(), "" );
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/copy.pass.cpp
new file mode 100644 (file)
index 0000000..74d5166
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+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<char8_t>::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<char8_t>::copy(NULL, s1, 0) == NULL);
+    assert(std::char_traits<char8_t>::copy(s1, NULL, 0) == s1);
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eof.pass.cpp
new file mode 100644 (file)
index 0000000..c48e3ae
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    std::char_traits<char8_t>::int_type i = std::char_traits<char8_t>::eof();
+    ((void)i); // Prevent unused warning
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq.pass.cpp
new file mode 100644 (file)
index 0000000..2b7d793
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert( std::char_traits<char8_t>::eq(u8'a', u8'a'));
+    assert(!std::char_traits<char8_t>::eq(u8'a', u8'A'));
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/eq_int_type.pass.cpp
new file mode 100644 (file)
index 0000000..15e645e
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert( std::char_traits<char8_t>::eq_int_type(u8'a', u8'a'));
+    assert(!std::char_traits<char8_t>::eq_int_type(u8'a', u8'A'));
+    assert(!std::char_traits<char8_t>::eq_int_type(std::char_traits<char8_t>::eof(), u8'A'));
+    assert( std::char_traits<char8_t>::eq_int_type(std::char_traits<char8_t>::eof(),
+                                                    std::char_traits<char8_t>::eof()));
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/find.pass.cpp
new file mode 100644 (file)
index 0000000..f358166
--- /dev/null
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+constexpr bool test_constexpr()
+{
+    constexpr const char8_t *p = u8"123";
+    return std::char_traits<char8_t>::find(p, 3, u8'1') == p
+        && std::char_traits<char8_t>::find(p, 3, u8'2') == p + 1
+        && std::char_traits<char8_t>::find(p, 3, u8'3') == p + 2
+        && std::char_traits<char8_t>::find(p, 3, u8'4') == nullptr;
+}
+
+int main()
+{
+    char8_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char8_t>::find(s1, 3, char8_t(1)) == s1);
+    assert(std::char_traits<char8_t>::find(s1, 3, char8_t(2)) == s1+1);
+    assert(std::char_traits<char8_t>::find(s1, 3, char8_t(3)) == s1+2);
+    assert(std::char_traits<char8_t>::find(s1, 3, char8_t(4)) == 0);
+    assert(std::char_traits<char8_t>::find(s1, 3, char8_t(0)) == 0);
+    assert(std::char_traits<char8_t>::find(NULL, 0, char8_t(0)) == 0);
+
+    static_assert(test_constexpr(), "" );
+}
+#else
+int main () {}
+#endif
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/length.pass.cpp
new file mode 100644 (file)
index 0000000..19f6c1e
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool test_constexpr()
+{
+    return std::char_traits<char8_t>::length(u8"") == 0
+        && std::char_traits<char8_t>::length(u8"abcd") == 4;
+}
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(std::char_traits<char8_t>::length(u8"") == 0);
+    assert(std::char_traits<char8_t>::length(u8"a") == 1);
+    assert(std::char_traits<char8_t>::length(u8"aa") == 2);
+    assert(std::char_traits<char8_t>::length(u8"aaa") == 3);
+    assert(std::char_traits<char8_t>::length(u8"aaaa") == 4);
+
+    static_assert(test_constexpr(), "");
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/lt.pass.cpp
new file mode 100644 (file)
index 0000000..73c703f
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(!std::char_traits<char8_t>::lt(u8'a', u8'a'));
+    assert( std::char_traits<char8_t>::lt(u8'A', u8'a'));
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/move.pass.cpp
new file mode 100644 (file)
index 0000000..688e559
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    char8_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char8_t>::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<char8_t>::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<char8_t>::move(NULL, s1, 0) == NULL);
+    assert(std::char_traits<char8_t>::move(s1, NULL, 0) == s1);
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/not_eof.pass.cpp
new file mode 100644 (file)
index 0000000..274d93f
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(std::char_traits<char8_t>::not_eof(u8'a') == u8'a');
+    assert(std::char_traits<char8_t>::not_eof(u8'A') == u8'A');
+    assert(std::char_traits<char8_t>::not_eof(0) == 0);
+    assert(std::char_traits<char8_t>::not_eof(std::char_traits<char8_t>::eof()) !=
+           std::char_traits<char8_t>::eof());
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_char_type.pass.cpp
new file mode 100644 (file)
index 0000000..9615920
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(std::char_traits<char8_t>::to_char_type(u8'a') == u8'a');
+    assert(std::char_traits<char8_t>::to_char_type(u8'A') == u8'A');
+    assert(std::char_traits<char8_t>::to_char_type(0) == 0);
+#endif
+}
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/to_int_type.pass.cpp
new file mode 100644 (file)
index 0000000..659be36
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert(std::char_traits<char8_t>::to_int_type(u8'a') == u8'a');
+    assert(std::char_traits<char8_t>::to_int_type(u8'A') == u8'A');
+    assert(std::char_traits<char8_t>::to_int_type(0) == 0);
+#endif
+}
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
new file mode 100644 (file)
index 0000000..64c27ff
--- /dev/null
@@ -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
+
+// <string>
+
+// template<> struct char_traits<char8_t>
+
+// typedef char8_t       char_type;
+// typedef unsigned int   int_type;
+// typedef streamoff      off_type;
+// typedef u16streampos   pos_type;
+// typedef mbstate_t      state_type;
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    static_assert((std::is_same<std::char_traits<char8_t>::char_type,  char8_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char8_t>::int_type,   unsigned int>::value), "");
+    static_assert((std::is_same<std::char_traits<char8_t>::off_type,   std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char8_t>::pos_type,   std::u16streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char8_t>::state_type, std::mbstate_t>::value), "");
+#endif
+}
index 3aba1c3..15d9712 100644 (file)
 // Test for the existence of:
 
 // basic_string typedef names
-// typedef basic_string<char> string;
+// typedef basic_string<char>     string;
 // typedef basic_string<char16_t> u16string;
+// typedef basic_string<char8_t>  u8string;  // C++20
 // typedef basic_string<char32_t> u32string;
-// typedef basic_string<wchar_t> wstring;
+// typedef basic_string<wchar_t>  wstring;
 
 #include <string>
 #include <type_traits>
 
+#include "test_macros.h"
+
 int main()
 {
     static_assert((std::is_same<std::string, std::basic_string<char> >::value), "");
     static_assert((std::is_same<std::wstring, std::basic_string<wchar_t> >::value), "");
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    static_assert((std::is_same<std::u8string, std::basic_string<char8_t> >::value), "");
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     static_assert((std::is_same<std::u16string, std::basic_string<char16_t> >::value), "");
     static_assert((std::is_same<std::u32string, std::basic_string<char32_t> >::value), "");
index b21ba04..fda67c3 100644 (file)
@@ -64,15 +64,13 @@ void test2 ( const CharT *s, size_t len ) {
 }
 
 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<string_view> ();
-    test1<u16string_view> ();
-    test1<u32string_view> ();
-    test1<wstring_view> ();
+    test1<std::string_view> ();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test1<std::u8string_view> ();
+#endif
+    test1<std::u16string_view> ();
+    test1<std::u32string_view> ();
+    test1<std::wstring_view> ();
 
     test2 ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
     test2 ( "ABCDE", 5 );
@@ -84,6 +82,13 @@ int main () {
     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 3307aa6..bab7889 100644 (file)
@@ -32,21 +32,27 @@ bool test (T sv0)
 
 int main () {
 
-    assert( test<std::string_view>    ( "1234"));
+    assert( test<std::string_view>    (  "1234"));
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    assert( test<std::u8string_view>  (u8"1234"));
+#endif
 #if TEST_STD_VER >= 11
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-    assert( test<std::u16string_view> (u"1234"));
-    assert( test<std::u32string_view> (U"1234"));
+    assert( test<std::u16string_view> ( u"1234"));
+    assert( test<std::u32string_view> ( U"1234"));
 #endif
 #endif
-    assert( test<std::wstring_view>   (L"1234"));
+    assert( test<std::wstring_view>   ( L"1234"));
 
 #if TEST_STD_VER > 11
-    static_assert( test<std::string_view>    ({ "abc", 3}), "");
+    static_assert( test<std::string_view>    ({  "abc", 3}), "");
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    static_assert( test<std::u8string_view>  ({u8"abc", 3}), "");
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-    static_assert( test<std::u16string_view> ({u"abc", 3}), "");
-    static_assert( test<std::u32string_view> ({U"abc", 3}), "");
+    static_assert( test<std::u16string_view> ({ u"abc", 3}), "");
+    static_assert( test<std::u32string_view> ({ U"abc", 3}), "");
 #endif
-    static_assert( test<std::wstring_view>   ({L"abc", 3}), "");
+    static_assert( test<std::wstring_view>   ({ L"abc", 3}), "");
 #endif
 }
index 79fadf6..0c94918 100644 (file)
@@ -37,14 +37,12 @@ void test () {
 }
 
 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<string_view> ();
-    test<u16string_view> ();
-    test<u32string_view> ();
-    test<wstring_view> ();
+    test<std::string_view> ();
+    test<std::u16string_view> ();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test<std::u8string_view> ();
+#endif
+    test<std::u32string_view> ();
+    test<std::wstring_view> ();
 
 }
index 5fad2bf..237d122 100644 (file)
@@ -42,6 +42,12 @@ int main () {
     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 2e9ebcb..70515bf 100644 (file)
@@ -23,6 +23,9 @@ int main() {
   {
     test_hash_enabled_for_type<std::string_view>();
     test_hash_enabled_for_type<std::wstring_view>();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test_hash_enabled_for_type<std::u8string_view>();
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     test_hash_enabled_for_type<std::u16string_view>();
     test_hash_enabled_for_type<std::u32string_view>();
index 53c3d26..042e1df 100644 (file)
@@ -59,6 +59,9 @@ test()
 int main()
 {
     test<std::string_view>();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test<std::u8string_view>();
+#endif
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     test<std::u16string_view>();
     test<std::u32string_view>();
index b766c51..339f1f8 100644 (file)
@@ -43,6 +43,9 @@ test(S s)
 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 @@ int main()
     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 @@ int main()
 #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 b5759d7..1533b49 100644 (file)
@@ -52,6 +52,9 @@ test(S s)
 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 @@ int main()
     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 @@ int main()
 #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 16a4da8..0ec8387 100644 (file)
@@ -44,6 +44,9 @@ test(S s)
 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 @@ int main()
     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 @@ int main()
 #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 08f9e5a..dfcb836 100644 (file)
@@ -52,6 +52,9 @@ test(S s)
 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 @@ int main()
     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 @@ int main()
 #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 0795338..cc2202e 100644 (file)
 
 #include "test_macros.h"
 
+#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<decltype(   "Hi"sv), std::string_view>::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<decltype( u8"Hi"sv), std::string_view>::value, "" );
-#endif
+    static_assert ( std::is_same<decltype( u8"Hi"sv), u8string_view>::value, "" );
     static_assert ( std::is_same<decltype(  L"Hi"sv), std::wstring_view>::value, "" );
     static_assert ( std::is_same<decltype(  u"Hi"sv), std::u16string_view>::value, "" );
     static_assert ( std::is_same<decltype(  U"Hi"sv), std::u32string_view>::value, "" );
 
     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 4c29959..2763f7f 100644 (file)
@@ -72,6 +72,9 @@ int main()
 {
     test<std::char_traits<char> >();
     test<std::char_traits<wchar_t> >();
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+    test<std::char_traits<char8_t> >();
+#endif
     static_assert((std::is_same<std::basic_string_view<char>::traits_type,
                                 std::char_traits<char> >::value), "");
 }
index fa81b11..85c2c98 100644 (file)
@@ -85,7 +85,7 @@ int main()
     test_is_integral<signed char>();
     test_is_integral<unsigned char>();
     test_is_integral<wchar_t>();
-#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
     test_is_integral<char8_t>();
 #endif