mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2025-03-03 09:17:09 +00:00
Second part of P0482 - char8_t. Reviewed as https://reviews.llvm.org/D55308
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21a8669ade
commit
96484477d1
@ -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)
|
||||
|
@ -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 <>
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -119,6 +119,7 @@ template<> class numeric_limits<cv long double>;
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
#include <version>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
@ -187,6 +187,7 @@ template <class charT> class messages_byname;
|
||||
#include <streambuf>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <version>
|
||||
#ifndef __APPLE__
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <any>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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
|
||||
|
||||
@ -19,13 +20,24 @@
|
||||
// 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
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <bit>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <charconv>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <complex>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
// XFAIL
|
||||
// #include <concepts>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <deque>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
// XFAIL
|
||||
// #include <execution>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -11,18 +11,30 @@
|
||||
// <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
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -20,13 +20,14 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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
|
||||
*/
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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
|
||||
*/
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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
|
||||
*/
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
// XFAIL
|
||||
// #include <memory_resource>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <mutex>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <optional>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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
|
||||
*/
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <scoped_allocator>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -19,6 +19,7 @@
|
||||
// UNSUPPORTED: libcpp-has-no-threads
|
||||
|
||||
#include <shared_mutex>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -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,12 +20,23 @@
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
@ -11,17 +11,29 @@
|
||||
// <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"
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -28,13 +28,14 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <unordered_map>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <unordered_set>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <variant>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main()
|
||||
|
@ -88,13 +88,14 @@
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
@ -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>();
|
||||
|
@ -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>();
|
||||
|
@ -15,48 +15,44 @@
|
||||
|
||||
#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() == 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"));
|
||||
}
|
||||
|
@ -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>{}};
|
||||
|
@ -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>{}};
|
||||
|
@ -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{};
|
||||
|
@ -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
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -12,18 +12,24 @@
|
||||
// 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), "");
|
||||
|
@ -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 );
|
||||
|
@ -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}), "");
|
||||
#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::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
|
||||
static_assert( test<std::wstring_view> ({L"abc", 3}), "");
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
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}), "");
|
||||
#endif
|
||||
}
|
||||
|
@ -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> ();
|
||||
|
||||
}
|
||||
|
@ -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""} );
|
||||
|
@ -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>();
|
||||
|
@ -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>();
|
||||
|
@ -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], "" );
|
||||
|
@ -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(), "" );
|
||||
|
@ -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], "" );
|
||||
|
@ -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], "" );
|
||||
|
@ -18,65 +18,55 @@
|
||||
|
||||
#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), "");
|
||||
|
@ -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), "");
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user