diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 15:39:13 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 15:39:13 +0000 |
commit | fd857c8184809f0fac54f7ec9d9e91477beb1b7d (patch) | |
tree | 58ed2d52992ba3dcfcc9e34d35ab3ed8b7aa76ed | |
parent | 78da6db1f23c0bfe8a36a5b5c05d06005037e556 (diff) |
Vendor import of libc++ release_40 branch r292009:vendor/libc++/libc++-release_40-r292009
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=312179
svn path=/vendor/libc++/libc++-release_40-r292009/; revision=312180; tag=vendor/libc++/libc++-release_40-r292009
30 files changed, 473 insertions, 81 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa0ed37e58e..a692f1b57a28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(libcxx CXX C) set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION 4.0.0svn) + set(PACKAGE_VERSION 4.0.0) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") diff --git a/cmake/Modules/HandleOutOfTreeLLVM.cmake b/cmake/Modules/HandleOutOfTreeLLVM.cmake index c772143244ae..7fee839d2732 100644 --- a/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ b/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -38,7 +38,18 @@ macro(find_llvm_parts) set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") - set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") + + # --cmakedir is supported since llvm r291218 (4.0 release) + execute_process( + COMMAND ${LLVM_CONFIG_PATH} --cmakedir + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT) + if(NOT HAD_ERROR) + string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH) + else() + set(LLVM_CMAKE_PATH + "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") + endif() else() set(LLVM_FOUND OFF) message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: " diff --git a/include/__config b/include/__config index fedec61126e1..b30b15c6fdb9 100644 --- a/include/__config +++ b/include/__config @@ -396,6 +396,15 @@ namespace std { #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif +// A constexpr version of __builtin_memcmp was added in clang 4.0 +#if __has_builtin(__builtin_memcmp) +# ifdef __apple_build_version__ +// No shipping version of Apple's clang has constexpr __builtin_memcmp +# elif __clang_major__ > 3 +# define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR +# endif +#endif + #elif defined(_LIBCPP_COMPILER_GCC) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -763,7 +772,7 @@ template <unsigned> struct __static_assert_check {}; #define _NOALIAS #endif -#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \ +#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions # define _LIBCPP_EXPLICIT explicit #else diff --git a/include/__mutex_base b/include/__mutex_base index cce928784a46..21638ee3292d 100644 --- a/include/__mutex_base +++ b/include/__mutex_base @@ -410,8 +410,8 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, typedef time_point<system_clock, duration<long double, nano> > __sys_tpf; typedef time_point<system_clock, nanoseconds> __sys_tpi; __sys_tpf _Max = __sys_tpi::max(); - system_clock::time_point __s_now = system_clock::now(); steady_clock::time_point __c_now = steady_clock::now(); + system_clock::time_point __s_now = system_clock::now(); if (_Max - __d > __s_now) __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d)); else diff --git a/include/__string b/include/__string index 0b851b9f9e2b..c85b874f054b 100644 --- a/include/__string +++ b/include/__string @@ -26,13 +26,14 @@ struct char_traits typedef streampos pos_type; typedef mbstate_t state_type; - static void assign(char_type& c1, const char_type& c2) noexcept; + static constexpr void assign(char_type& c1, const char_type& c2) noexcept; static constexpr bool eq(char_type c1, char_type c2) noexcept; static constexpr bool lt(char_type c1, char_type c2) noexcept; - static int compare(const char_type* s1, const char_type* s2, size_t n); - static size_t length(const char_type* s); - static const char_type* find(const char_type* s, size_t n, const char_type& a); + static constexpr int compare(const char_type* s1, const char_type* s2, size_t n); + static constexpr size_t length(const char_type* s); + static constexpr const char_type* + find(const char_type* s, size_t n, const char_type& a); static char_type* move(char_type* s1, const char_type* s2, size_t n); static char_type* copy(char_type* s1, const char_type* s2, size_t n); static char_type* assign(char_type* s, size_t n, char_type a); @@ -77,18 +78,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits typedef streampos pos_type; typedef mbstate_t state_type; - static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT - {__c1 = __c2;} + static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14 + assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} - static int compare(const char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static size_t length(const char_type* __s); - _LIBCPP_INLINE_VISIBILITY - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); @@ -108,7 +110,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits }; template <class _CharT> -int +_LIBCPP_CONSTEXPR_AFTER_CXX14 int char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) { for (; __n; --__n, ++__s1, ++__s2) @@ -123,7 +125,7 @@ char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_ template <class _CharT> inline -size_t +_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t char_traits<_CharT>::length(const char_type* __s) { size_t __len = 0; @@ -134,7 +136,7 @@ char_traits<_CharT>::length(const char_type* __s) template <class _CharT> inline -const _CharT* +_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT* char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) { for (; __n; --__n) @@ -200,18 +202,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> typedef streampos pos_type; typedef mbstate_t state_type; - static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT - {__c1 = __c2;} + static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 + void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return (unsigned char)__c1 < (unsigned char)__c2;} - static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);} - static inline size_t length(const char_type* __s) _NOEXCEPT {return strlen(__s);} - static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT - {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);} + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 + length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; static inline 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 inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT @@ -234,6 +237,48 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> {return int_type(EOF);} }; +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +int +char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT +{ + if (__n == 0) + return 0; +#ifdef _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR + return __builtin_memcmp(__s1, __s2, __n); +#elif _LIBCPP_STD_VER <= 14 + return 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 +} + +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +const char* +char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT +{ + if (__n == 0) + return NULL; +#if _LIBCPP_STD_VER <= 14 + return (const char_type*) memchr(__s, to_int_type(__a), __n); +#else + for (; __n; --__n) + { + if (eq(*__s, __a)) + return __s; + ++__s; + } + return NULL; +#endif +} + + // char_traits<wchar_t> template <> @@ -245,19 +290,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> typedef streampos pos_type; typedef mbstate_t state_type; - static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT - {__c1 = __c2;} + static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 + void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} - static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);} - static inline size_t length(const char_type* __s) _NOEXCEPT - {return wcslen(__s);} - static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT - {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);} + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + size_t length(const char_type* __s) _NOEXCEPT; + static _LIBCPP_CONSTEXPR_AFTER_CXX14 + const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT @@ -280,6 +325,66 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> {return int_type(WEOF);} }; +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +int +char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT +{ + if (__n == 0) + return 0; +#if __has_builtin(__builtin_wmemcmp) + return __builtin_wmemcmp(__s1, __s2, __n); +#elif _LIBCPP_STD_VER <= 14 + return wmemcmp(__s1, __s2, __n); +#else + for (; __n; --__n, ++__s1, ++__s2) + { + if (lt(*__s1, *__s2)) + return -1; + if (lt(*__s2, *__s1)) + return 1; + } + return 0; +#endif +} + +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +size_t +char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT +{ +#if __has_builtin(__builtin_wcslen) + return __builtin_wcslen(__s); +#elif _LIBCPP_STD_VER <= 14 + return wcslen(__s); +#else + size_t __len = 0; + for (; !eq(*__s, char_type(0)); ++__s) + ++__len; + return __len; +#endif +} + +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +const wchar_t* +char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT +{ + if (__n == 0) + return NULL; +#if __has_builtin(__builtin_wmemchr) + return __builtin_wmemchr(__s, __a, __n); +#elif _LIBCPP_STD_VER <= 14 + return wmemchr(__s, __a, __n); +#else + for (; __n; --__n) + { + if (eq(*__s, __a)) + return __s; + ++__s; + } + return NULL; +#endif +} + + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> @@ -291,19 +396,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> typedef u16streampos pos_type; typedef mbstate_t state_type; - static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT - {__c1 = __c2;} + static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 + void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} - _LIBCPP_INLINE_VISIBILITY - static int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + size_t length(const char_type* __s) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -323,7 +428,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> {return int_type(0xFFFF);} }; -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 int char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { @@ -337,7 +442,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT { @@ -347,7 +452,7 @@ char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT return __len; } -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 const char16_t* char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { @@ -410,19 +515,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> typedef u32streampos pos_type; typedef mbstate_t state_type; - static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT - {__c1 = __c2;} + static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 + void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} - _LIBCPP_INLINE_VISIBILITY - static int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + size_t length(const char_type* __s) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 + const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -442,7 +547,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> {return int_type(0xFFFFFFFF);} }; -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 int char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { @@ -456,7 +561,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT { @@ -466,7 +571,7 @@ char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT return __len; } -inline +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 const char32_t* char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { diff --git a/include/__threading_support b/include/__threading_support index b2c3b1fc6376..a672a9f80eda 100644 --- a/include/__threading_support +++ b/include/__threading_support @@ -385,7 +385,7 @@ int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m) int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m) { - static_cast<void>(__m); + DeleteCriticalSection(__m); return 0; } diff --git a/include/experimental/string_view b/include/experimental/string_view index 674f6c355fb4..41c0d34d3c84 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -340,12 +340,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS // [string.view.ops], string operations: template<class _Allocator> _LIBCPP_INLINE_VISIBILITY - // Clang's extended C++11 explict conversions don't work with - // string_view in C++03. -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_EXPLICIT -#endif - operator basic_string<_CharT, _Traits, _Allocator>() const + _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); } template<class _Allocator = allocator<_CharT> > diff --git a/include/ios b/include/ios index efee39fb533a..bb5ca72e5e4d 100644 --- a/include/ios +++ b/include/ios @@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate) clear(__rdstate_); } +#if defined(_LIBCPP_CXX03_LANG) +struct _LIBCPP_TYPE_VIS __cxx03_bool { + typedef void (__cxx03_bool::*__bool_type)(); + void __true_value() {} +}; +#endif + template <class _CharT, class _Traits> class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base @@ -585,8 +592,15 @@ public: typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; +#if defined(_LIBCPP_CXX03_LANG) + _LIBCPP_ALWAYS_INLINE + operator __cxx03_bool::__bool_type() const { + return !fail() ? &__cxx03_bool::__true_value : nullptr; + } +#else _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT operator bool() const {return !fail();} +#endif _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} diff --git a/include/memory b/include/memory index 54fd7bf49e89..2a25f0ecb507 100644 --- a/include/memory +++ b/include/memory @@ -3884,6 +3884,7 @@ class _LIBCPP_TEMPLATE_VIS shared_ptr { public: typedef _Tp element_type; + #if _LIBCPP_STD_VER > 14 typedef weak_ptr<_Tp> weak_type; #endif @@ -3914,17 +3915,17 @@ public: template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr&& __r) _NOEXCEPT; template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r, @@ -4316,7 +4317,7 @@ template<class _Tp> template<class _Yp> inline shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4341,7 +4342,7 @@ template<class _Tp> template<class _Yp> inline shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4639,7 +4640,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp>& >::type shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT @@ -4664,7 +4665,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp>& >::type shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) @@ -4679,7 +4680,7 @@ inline typename enable_if < !is_array<_Yp>::value && - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp> >::type& shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) @@ -4694,7 +4695,8 @@ inline typename enable_if < !is_array<_Yp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, + is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, + typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp>& >::type shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) @@ -4711,7 +4713,7 @@ inline _LIBCPP_INLINE_VISIBILITY typename enable_if < !is_array<_Yp>::value && - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp>& >::type shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) @@ -4726,7 +4728,8 @@ inline _LIBCPP_INLINE_VISIBILITY typename enable_if < !is_array<_Yp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, + is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, + typename shared_ptr<_Tp>::element_type*>::value, shared_ptr<_Tp>& >::type shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) @@ -4759,7 +4762,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, void >::type shared_ptr<_Tp>::reset(_Yp* __p) @@ -4772,7 +4775,7 @@ template<class _Yp, class _Dp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, void >::type shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) @@ -4785,7 +4788,7 @@ template<class _Yp, class _Dp, class _Alloc> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, void >::type shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) @@ -5350,7 +5353,7 @@ weak_ptr<_Tp>::reset() _NOEXCEPT template<class _Tp> template<class _Yp> shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) + typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { diff --git a/include/mutex b/include/mutex index 8526533f1402..3b878c642cce 100644 --- a/include/mutex +++ b/include/mutex @@ -559,6 +559,7 @@ public: #endif template <class _Fp> +inline _LIBCPP_INLINE_VISIBILITY void __call_once_proxy(void* __vp) { diff --git a/src/chrono.cpp b/src/chrono.cpp index df5cabdb1845..9b277a610cd2 100644 --- a/src/chrono.cpp +++ b/src/chrono.cpp @@ -42,7 +42,7 @@ #include <winapifamily.h> #endif #else -#if !defined(CLOCK_REALTIME) +#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME) #include <sys/time.h> // for gettimeofday and timeval #endif // !defined(CLOCK_REALTIME) #endif // defined(_LIBCPP_WIN32API) diff --git a/src/new.cpp b/src/new.cpp index 782aac90fb7a..2ef8939fdcb3 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -198,7 +198,11 @@ void operator delete(void* ptr, std::align_val_t) _NOEXCEPT { if (ptr) +#if defined(_LIBCPP_MSVCRT) + ::_aligned_free(ptr); +#else ::free(ptr); +#endif } _LIBCPP_WEAK diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp index 2c3deaefd063..311064ceb614 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp @@ -11,14 +11,30 @@ // template<> struct char_traits<char> -// static void assign(char_type& c1, const char_type& c2); +// static constexpr void assign(char_type& c1, const char_type& c2); // constexpr in C++17 +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + char c = '1'; + std::char_traits<char>::assign(c, 'a'); + return c == 'a'; +} +#endif + int main() { char c = '\0'; std::char_traits<char>::assign(c, 'a'); assert(c == 'a'); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp index ba58684b8e2e..71ab24898d60 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp @@ -12,10 +12,22 @@ // template<> struct char_traits<char> // static int compare(const char_type* s1, const char_type* s2, size_t n); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char>::compare("123", "223", 3) < 0 + && std::char_traits<char>::compare("223", "123", 3) > 0 + && std::char_traits<char>::compare("123", "123", 3) == 0; +} +#endif + int main() { assert(std::char_traits<char>::compare("", "", 0) == 0); @@ -38,4 +50,8 @@ int main() assert(std::char_traits<char>::compare("223", "123", 3) > 0); assert(std::char_traits<char>::compare("133", "123", 3) > 0); assert(std::char_traits<char>::compare("124", "123", 3) > 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp index a640af28d8ac..714202e25685 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp @@ -12,10 +12,24 @@ // template<> struct char_traits<char> // static const char_type* find(const char_type* s, size_t n, const char_type& a); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + constexpr const char *p = "123"; + return std::char_traits<char>::find(p, 3, '1') == p + && std::char_traits<char>::find(p, 3, '2') == p + 1 + && std::char_traits<char>::find(p, 3, '3') == p + 2 + && std::char_traits<char>::find(p, 3, '4') == nullptr; +} +#endif + int main() { char s1[] = {1, 2, 3}; @@ -25,4 +39,8 @@ int main() assert(std::char_traits<char>::find(s1, 3, char(4)) == 0); assert(std::char_traits<char>::find(s1, 3, char(0)) == 0); assert(std::char_traits<char>::find(NULL, 0, char(0)) == 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp index 56844ef46644..d93e499873b6 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp @@ -12,10 +12,22 @@ // template<> struct char_traits<char> // static size_t length(const char_type* s); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char>::length("") == 0 + && std::char_traits<char>::length("abcd") == 4; +} +#endif + + int main() { assert(std::char_traits<char>::length("") == 0); @@ -23,4 +35,8 @@ int main() assert(std::char_traits<char>::length("aa") == 2); assert(std::char_traits<char>::length("aaa") == 3); assert(std::char_traits<char>::length("aaaa") == 4); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp index 7f223af57414..e28f906c05bb 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp @@ -12,12 +12,22 @@ // template<> struct char_traits<char16_t> // static void assign(char_type& c1, const char_type& c2); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + char16_t c = u'1'; + std::char_traits<char16_t>::assign(c, u'a'); + return c == u'a'; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -26,5 +36,9 @@ int main() std::char_traits<char16_t>::assign(c, u'a'); assert(c == u'a'); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp index 7356097a6677..b4be1402ad1c 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp @@ -12,12 +12,23 @@ // template<> struct char_traits<char16_t> // static int compare(const char_type* s1, const char_type* s2, size_t n); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0 + && std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0 + && std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0; +} +#endif + + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -43,5 +54,9 @@ int main() assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0); assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp index 22db05b55a87..852451cb827e 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp @@ -12,10 +12,24 @@ // template<> struct char_traits<char16_t> // static const char_type* find(const char_type* s, size_t n, const char_type& a); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + constexpr const char16_t *p = u"123"; + return std::char_traits<char16_t>::find(p, 3, u'1') == p + && std::char_traits<char16_t>::find(p, 3, u'2') == p + 1 + && std::char_traits<char16_t>::find(p, 3, u'3') == p + 2 + && std::char_traits<char16_t>::find(p, 3, u'4') == nullptr; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -26,5 +40,9 @@ int main() assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0); assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0); assert(std::char_traits<char16_t>::find(NULL, 0, char16_t(0)) == 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp index ff5a2a934a9f..5d882bde2f5a 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp @@ -12,12 +12,21 @@ // template<> struct char_traits<char16_t> // static size_t length(const char_type* s); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char16_t>::length(u"") == 0 + && std::char_traits<char16_t>::length(u"abcd") == 4; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -28,5 +37,9 @@ int main() assert(std::char_traits<char16_t>::length(u"aaa") == 3); assert(std::char_traits<char16_t>::length(u"aaaa") == 4); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp index 6cd55ea58bff..373931169d81 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp @@ -12,12 +12,22 @@ // template<> struct char_traits<char32_t> // static void assign(char_type& c1, const char_type& c2); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + char32_t c = U'1'; + std::char_traits<char32_t>::assign(c, U'a'); + return c == U'a'; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -26,5 +36,9 @@ int main() std::char_traits<char32_t>::assign(c, U'a'); assert(c == U'a'); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp index 2671b5624100..1730d06cc16a 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp @@ -12,12 +12,22 @@ // template<> struct char_traits<char32_t> // static int compare(const char_type* s1, const char_type* s2, size_t n); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0 + && std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0 + && std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -43,5 +53,9 @@ int main() assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0); assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp index d0b17999d3e1..6d201db62efc 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp @@ -12,10 +12,24 @@ // template<> struct char_traits<char32_t> // static const char_type* find(const char_type* s, size_t n, const char_type& a); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + constexpr const char32_t *p = U"123"; + return std::char_traits<char32_t>::find(p, 3, U'1') == p + && std::char_traits<char32_t>::find(p, 3, U'2') == p + 1 + && std::char_traits<char32_t>::find(p, 3, U'3') == p + 2 + && std::char_traits<char32_t>::find(p, 3, U'4') == nullptr; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -26,5 +40,9 @@ int main() assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0); assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0); assert(std::char_traits<char32_t>::find(NULL, 0, char32_t(0)) == 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp index e0bee5dc5080..9d691aca4ec9 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp @@ -12,12 +12,21 @@ // template<> struct char_traits<char32_t> // static size_t length(const char_type* s); +// constexpr in C++17 #include <string> #include <cassert> #include "test_macros.h" +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<char32_t>::length(U"") == 0 + && std::char_traits<char32_t>::length(U"abcd") == 4; +} +#endif + int main() { #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -28,5 +37,9 @@ int main() assert(std::char_traits<char32_t>::length(U"aaa") == 3); assert(std::char_traits<char32_t>::length(U"aaaa") == 4); #endif + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp index 7dcf08c2e76f..7a317f0d66de 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp @@ -12,13 +12,29 @@ // template<> struct char_traits<wchar_t> // static void assign(char_type& c1, const char_type& c2); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + wchar_t c = L'1'; + std::char_traits<wchar_t>::assign(c, L'a'); + return c == L'a'; +} +#endif + int main() { wchar_t c = L'\0'; std::char_traits<wchar_t>::assign(c, L'a'); assert(c == L'a'); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp index 124201bb82f3..894560d69396 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp @@ -12,10 +12,22 @@ // template<> struct char_traits<wchar_t> // static int compare(const char_type* s1, const char_type* s2, size_t n); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0 + && std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0 + && std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0; +} +#endif + int main() { assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0); @@ -38,4 +50,8 @@ int main() assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0); assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0); assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp index ead3f32fcc72..80aca0ea7f9d 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp @@ -12,10 +12,24 @@ // template<> struct char_traits<wchar_t> // static const char_type* find(const char_type* s, size_t n, const char_type& a); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + constexpr const wchar_t *p = L"123"; + return std::char_traits<wchar_t>::find(p, 3, L'1') == p + && std::char_traits<wchar_t>::find(p, 3, L'2') == p + 1 + && std::char_traits<wchar_t>::find(p, 3, L'3') == p + 2 + && std::char_traits<wchar_t>::find(p, 3, L'4') == nullptr; +} +#endif + int main() { wchar_t s1[] = {1, 2, 3}; @@ -25,4 +39,8 @@ int main() assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0); assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0); assert(std::char_traits<wchar_t>::find(NULL, 0, wchar_t(0)) == 0); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp index 691e968ed246..35cbb2d5fd47 100644 --- a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp @@ -12,10 +12,21 @@ // template<> struct char_traits<wchar_t> // static size_t length(const char_type* s); +// constexpr in C++17 #include <string> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ + return std::char_traits<wchar_t>::length(L"") == 0 + && std::char_traits<wchar_t>::length(L"abcd") == 4; +} +#endif + int main() { assert(std::char_traits<wchar_t>::length(L"") == 0); @@ -23,4 +34,8 @@ int main() assert(std::char_traits<wchar_t>::length(L"aa") == 2); assert(std::char_traits<wchar_t>::length(L"aaa") == 3); assert(std::char_traits<wchar_t>::length(L"aaaa") == 4); + +#if TEST_STD_VER > 14 + static_assert(test_constexpr(), "" ); +#endif } diff --git a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp index af061268410d..39a8e517daef 100644 --- a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 diff --git a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp index 03d7c915cb61..af908d7e77ad 100644 --- a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 |