diff options
| author | joerg <joerg@NetBSD.org> | 2013-11-11 23:42:23 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2013-11-11 23:42:23 +0000 |
| commit | 7b508f5cf1cffaba9056e779bab2a09bf6767655 (patch) | |
| tree | 1ded8b22c412394ce3b7605b7da7e7d752c5b1e4 /external/bsd/libc++ | |
| parent | f4c7577e0d6de880acbb5d05bffab23df87c32d5 (diff) | |
Import libc++ r194207. This brings in various bug fixes, a good chunk of
support for the up-coming C++14 and improved compatibility with various
compilers other than Clang.
Diffstat (limited to 'external/bsd/libc++')
457 files changed, 14324 insertions, 2145 deletions
diff --git a/external/bsd/libc++/dist/libcxx/CREDITS.TXT b/external/bsd/libc++/dist/libcxx/CREDITS.TXT index e33699865e2..368b526fcc1 100644 --- a/external/bsd/libc++/dist/libcxx/CREDITS.TXT +++ b/external/bsd/libc++/dist/libcxx/CREDITS.TXT @@ -31,7 +31,7 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. N: Marshall Clow E: mclow.lists@gmail.com E: marshall@idio.com -D: Minor patches and bug fixes. +D: C++14 support, patches and bug fixes. N: Bill Fisher E: william.w.fisher@gmail.com diff --git a/external/bsd/libc++/dist/libcxx/include/__bit_reference b/external/bsd/libc++/dist/libcxx/include/__bit_reference index 39a9dc3c0cc..37b79237128 100644 --- a/external/bsd/libc++/dist/libcxx/include/__bit_reference +++ b/external/bsd/libc++/dist/libcxx/include/__bit_reference @@ -40,7 +40,7 @@ class __bit_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) || defined(__IBMCPP__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -82,7 +82,7 @@ class __bit_reference<_Cp, false> }; template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -92,7 +92,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT } template <class _Cp, class _Dp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT { @@ -102,7 +102,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT { @@ -112,7 +112,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -130,7 +130,7 @@ class __bit_const_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) || defined(__IBMCPP__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -379,7 +379,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) { @@ -1222,7 +1222,7 @@ private: __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT : __seg_(__s), __ctz_(__ctz) {} -#if defined(__clang__) || defined(__IBMCPP__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; diff --git a/external/bsd/libc++/dist/libcxx/include/__config b/external/bsd/libc++/dist/libcxx/include/__config index 46e84bc0aac..a45b02de035 100644 --- a/external/bsd/libc++/dist/libcxx/include/__config +++ b/external/bsd/libc++/dist/libcxx/include/__config @@ -79,8 +79,14 @@ # endif # if defined(_MSC_VER) && !defined(__clang__) # define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler +# define _LIBCPP_TOSTRING2(x) #x +# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) +# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) +# endif +# // If mingw not explicitly detected, assume using MS C runtime only. +# ifndef __MINGW32__ +# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif -# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library #endif // _WIN32 #ifdef __linux__ @@ -191,10 +197,6 @@ #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS #endif -#ifndef _LIBCPP_CANTTHROW -#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) -#endif - #ifndef _LIBCPP_ALWAYS_INLINE #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif @@ -419,6 +421,7 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) @@ -431,6 +434,7 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std +# define _LIBCPP_WEAK namespace std { } @@ -529,8 +533,23 @@ template <unsigned> struct __static_assert_check {}; #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS +#ifdef _LIBCPP_DEBUG +# if _LIBCPP_DEBUG == 0 +# define _LIBCPP_DEBUG_LEVEL 1 +# elif _LIBCPP_DEBUG == 1 +# define _LIBCPP_DEBUG_LEVEL 2 +# else +# error Supported values for _LIBCPP_DEBUG are 0 and 1 +# endif +# define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + #ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +#define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + +#ifndef _LIBCPP_EXTERN_TEMPLATE2 +#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__) @@ -548,16 +567,6 @@ template <unsigned> struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#ifdef _LIBCPP_DEBUG2 -# if _LIBCPP_DEBUG2 == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG2 == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG2 are 0 and 1 -# endif -#endif - #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 @@ -566,10 +575,36 @@ template <unsigned> struct __static_assert_check {}; # endif #endif // _LIBCPP_STD_VER +#if _LIBCPP_STD_VER > 11 +#define _LIBCPP_DEPRECATED [[deprecated]] +#else +#define _LIBCPP_DEPRECATED +#endif + #if _LIBCPP_STD_VER <= 11 #define _LIBCPP_CONSTEXPR_AFTER_CXX11 +#define _LIBCPP_EXPLICIT_AFTER_CXX11 +#define _LIBCPP_DEPRECATED_AFTER_CXX11 #else #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit +#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] +#endif + +// Try to find out if RTTI is disabled. +// g++ and cl.exe have RTTI on by default and define a macro when it is. +// g++ only defines the macro in 4.3.2 and onwards. +#if !defined(_LIBCPP_NO_RTTI) +# if defined(__GNUG__) && (__GNUC__ >= 4 && \ + (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI) +# define _LIBCPP_NO_RTTI +# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) +# define _LIBCPP_NO_RTTI +# endif +#endif + +#ifndef _LIBCPP_WEAK +# define _LIBCPP_WEAK __attribute__((__weak__)) #endif #endif // _LIBCPP_CONFIG diff --git a/external/bsd/libc++/dist/libcxx/include/__debug b/external/bsd/libc++/dist/libcxx/include/__debug index bac580cfa80..f1805adcfe4 100644 --- a/external/bsd/libc++/dist/libcxx/include/__debug +++ b/external/bsd/libc++/dist/libcxx/include/__debug @@ -11,6 +11,10 @@ #ifndef _LIBCPP_DEBUG_H #define _LIBCPP_DEBUG_H +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #if _LIBCPP_DEBUG_LEVEL >= 1 # include <cstdlib> @@ -24,10 +28,6 @@ #if _LIBCPP_DEBUG_LEVEL >= 2 -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_TYPE_VIS __c_node; @@ -38,8 +38,15 @@ struct _LIBCPP_TYPE_VIS __i_node __i_node* __next_; __c_node* __c_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __i_node(const __i_node&) = delete; __i_node& operator=(const __i_node&) = delete; +#else +private: + __i_node(const __i_node&); + __i_node& operator=(const __i_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __i_node(void* __i, __i_node* __next, __c_node* __c) : __i_(__i), __next_(__next), __c_(__c) {} @@ -54,8 +61,15 @@ struct _LIBCPP_TYPE_VIS __c_node __i_node** end_; __i_node** cap_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __c_node(const __c_node&) = delete; __c_node& operator=(const __c_node&) = delete; +#else +private: + __c_node(const __c_node&); + __c_node& operator=(const __c_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __c_node(void* __c, __c_node* __next) : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} @@ -134,8 +148,15 @@ class _LIBCPP_TYPE_VIS __libcpp_db __libcpp_db(); public: +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __libcpp_db(const __libcpp_db&) = delete; __libcpp_db& operator=(const __libcpp_db&) = delete; +#else +private: + __libcpp_db(const __libcpp_db&); + __libcpp_db& operator=(const __libcpp_db&); +public: +#endif ~__libcpp_db(); class __db_c_iterator; diff --git a/external/bsd/libc++/dist/libcxx/include/__functional_base b/external/bsd/libc++/dist/libcxx/include/__functional_base index 72da75971b9..1c337d8b4bf 100644 --- a/external/bsd/libc++/dist/libcxx/include/__functional_base +++ b/external/bsd/libc++/dist/libcxx/include/__functional_base @@ -15,6 +15,7 @@ #include <type_traits> #include <typeinfo> #include <exception> +#include <new> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -57,7 +58,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} }; @@ -65,7 +67,8 @@ struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY less<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -515,6 +518,97 @@ public: }; #endif +// allocator_arg_t + +struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { }; + +#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) +extern const allocator_arg_t allocator_arg; +#else +constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#endif + +// uses_allocator + +template <class _Tp> +struct __has_allocator_type +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::allocator_type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> +struct __uses_allocator + : public integral_constant<bool, + is_convertible<_Alloc, typename _Tp::allocator_type>::value> +{ +}; + +template <class _Tp, class _Alloc> +struct __uses_allocator<_Tp, _Alloc, false> + : public false_type +{ +}; + +template <class _Tp, class _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator + : public __uses_allocator<_Tp, _Alloc> +{ +}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +// allocator construction + +template <class _Tp, class _Alloc, class ..._Args> +struct __uses_alloc_ctor_imp +{ + static const bool __ua = uses_allocator<_Tp, _Alloc>::value; + static const bool __ic = + is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + static const int value = __ua ? 2 - __ic : 0; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __uses_alloc_ctor + : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> + {}; + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args) +{ + __user_alloc_construct_impl( + __uses_alloc_ctor<_Tp, _Allocator>(), + __storage, __a, _VSTD::forward<_Args>(__args)... + ); +} +#endif // _LIBCPP_HAS_NO_VARIADICS _LIBCPP_END_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/include/__hash_table b/external/bsd/libc++/dist/libcxx/include/__hash_table index 880ef967e17..4c4feb03eab 100644 --- a/external/bsd/libc++/dist/libcxx/include/__hash_table +++ b/external/bsd/libc++/dist/libcxx/include/__hash_table @@ -20,7 +20,7 @@ #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -2101,7 +2101,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v, __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return __h; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2116,7 +2116,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2132,7 +2132,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Tp, class _Hash, class _Equal, class _Alloc> diff --git a/external/bsd/libc++/dist/libcxx/include/__locale b/external/bsd/libc++/dist/libcxx/include/__locale index 9c51f9ef705..2073e1b8edf 100644 --- a/external/bsd/libc++/dist/libcxx/include/__locale +++ b/external/bsd/libc++/dist/libcxx/include/__locale @@ -19,7 +19,7 @@ #include <cstdint> #include <cctype> #include <locale.h> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # include <support/win32/locale_win32.h> #elif _AIX # include <support/ibm/xlocale.h> @@ -256,8 +256,8 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const return static_cast<long>(__h); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>) // template <class CharT> class collate_byname; @@ -363,7 +363,7 @@ public: # else static const mask blank = _CTYPE_B; # endif -#elif defined(__sun__) +#elif defined(__sun__) || defined(_AIX) typedef unsigned int mask; static const mask space = _ISSPACE; static const mask print = _ISPRINT; @@ -512,7 +512,7 @@ public: _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { - return isascii(__c) ? __tab_[static_cast<int>(__c)] & __m : false; + return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false; } _LIBCPP_ALWAYS_INLINE @@ -1147,10 +1147,10 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() { } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); diff --git a/external/bsd/libc++/dist/libcxx/include/__mutex_base b/external/bsd/libc++/dist/libcxx/include/__mutex_base index a73e400e655..d4023a64f9f 100644 --- a/external/bsd/libc++/dist/libcxx/include/__mutex_base +++ b/external/bsd/libc++/dist/libcxx/include/__mutex_base @@ -20,16 +20,6 @@ #pragma GCC system_header #endif -#ifdef _LIBCPP_SHARED_LOCK - -namespace ting { -template <class _Mutex> class shared_lock; -template <class _Mutex> class upgrade_lock; -} - -#endif // _LIBCPP_SHARED_LOCK - - _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS mutex @@ -162,27 +152,6 @@ public: return *this; } -#ifdef _LIBCPP_SHARED_LOCK - - unique_lock(ting::shared_lock<mutex_type>&&, try_to_lock_t); - template <class _Clock, class _Duration> - unique_lock(ting::shared_lock<mutex_type>&&, - const chrono::time_point<_Clock, _Duration>&); - template <class _Rep, class _Period> - unique_lock(ting::shared_lock<mutex_type>&&, - const chrono::duration<_Rep, _Period>&); - - explicit unique_lock(ting::upgrade_lock<mutex_type>&&); - unique_lock(ting::upgrade_lock<mutex_type>&&, try_to_lock_t); - template <class _Clock, class _Duration> - unique_lock(ting::upgrade_lock<mutex_type>&&, - const chrono::time_point<_Clock, _Duration>&); - template <class _Rep, class _Period> - unique_lock(ting::upgrade_lock<mutex_type>&&, - const chrono::duration<_Rep, _Period>&); - -#endif // _LIBCPP_SHARED_LOCK - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void lock(); diff --git a/external/bsd/libc++/dist/libcxx/include/__split_buffer b/external/bsd/libc++/dist/libcxx/include/__split_buffer index f1c404f7741..1d529cbe27d 100644 --- a/external/bsd/libc++/dist/libcxx/include/__split_buffer +++ b/external/bsd/libc++/dist/libcxx/include/__split_buffer @@ -285,7 +285,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { @@ -294,7 +294,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { @@ -302,7 +302,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { @@ -311,7 +311,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT { @@ -328,7 +328,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) @@ -336,14 +336,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { @@ -541,7 +541,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) { @@ -640,7 +640,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/external/bsd/libc++/dist/libcxx/include/__tree b/external/bsd/libc++/dist/libcxx/include/__tree index 67f0a2b6c1b..acf87593a97 100644 --- a/external/bsd/libc++/dist/libcxx/include/__tree +++ b/external/bsd/libc++/dist/libcxx/include/__tree @@ -1854,7 +1854,7 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v) __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/external/bsd/libc++/dist/libcxx/include/__undef_min_max b/external/bsd/libc++/dist/libcxx/include/__undef_min_max index b1e80d1b049..2b6bc90a125 100644 --- a/external/bsd/libc++/dist/libcxx/include/__undef_min_max +++ b/external/bsd/libc++/dist/libcxx/include/__undef_min_max @@ -9,11 +9,19 @@ //===----------------------------------------------------------------------===// #ifdef min +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro min is incompatible with C++. #undefing min") +#else #warning: macro min is incompatible with C++. #undefing min +#endif #undef min #endif #ifdef max +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro max is incompatible with C++. #undefing max") +#else #warning: macro max is incompatible with C++. #undefing max +#endif #undef max #endif diff --git a/external/bsd/libc++/dist/libcxx/include/algorithm b/external/bsd/libc++/dist/libcxx/include/algorithm index 053b809fa99..367489fbb83 100644 --- a/external/bsd/libc++/dist/libcxx/include/algorithm +++ b/external/bsd/libc++/dist/libcxx/include/algorithm @@ -631,6 +631,9 @@ template <class BidirectionalIterator, class Compare> #if defined(__IBMCPP__) #include "support/ibm/support.h" #endif +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include "support/win32/support.h" +#endif #include <__undef_min_max> @@ -714,7 +717,7 @@ public: bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);} }; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG template <class _Compare> struct __debug_less @@ -731,7 +734,7 @@ struct __debug_less } }; -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG // Precondition: __x != 0 inline _LIBCPP_INLINE_VISIBILITY @@ -829,7 +832,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _VSTD::move(__f); + return _VSTD::move(__f); // explicitly moved for (emulated) C++03 } // find @@ -1692,6 +1695,8 @@ __unwrap_iter(move_iterator<_Tp*> __i) return __i.base(); } +#if _LIBCPP_DEBUG_LEVEL < 2 + template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY typename enable_if @@ -1704,6 +1709,8 @@ __unwrap_iter(__wrap_iter<_Tp*> __i) return __i.base(); } +#endif // _LIBCPP_DEBUG_LEVEL < 2 + template <class _InputIterator, class _OutputIterator> inline _LIBCPP_INLINE_VISIBILITY _OutputIterator @@ -3949,14 +3956,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4062,14 +4069,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lower_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4110,14 +4117,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __upper_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4170,14 +4177,14 @@ inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __equal_range<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4205,14 +4212,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __binary_search<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4255,14 +4262,14 @@ _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -4429,16 +4436,16 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -4640,14 +4647,14 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar __buf = _VSTD::get_temporary_buffer<value_type>(__len); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4789,14 +4796,14 @@ inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4827,14 +4834,14 @@ inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4867,14 +4874,14 @@ inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __make_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __make_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4901,14 +4908,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4945,14 +4952,14 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __partial_sort<_Comp_ref>(__first, __middle, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4995,14 +5002,14 @@ _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator, class _RandomAccessIterator> @@ -5209,14 +5216,14 @@ inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __nth_element<_Comp_ref>(__first, __nth, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __nth_element<_Comp_ref>(__first, __nth, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -5250,14 +5257,14 @@ bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> @@ -5303,14 +5310,14 @@ _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5355,14 +5362,14 @@ _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5409,14 +5416,14 @@ _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5468,14 +5475,14 @@ _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5512,14 +5519,14 @@ bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> @@ -5567,14 +5574,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __next_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __next_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -5620,14 +5627,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __prev_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __prev_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> diff --git a/external/bsd/libc++/dist/libcxx/include/array b/external/bsd/libc++/dist/libcxx/include/array index 3174fe943f5..d37075da1a2 100644 --- a/external/bsd/libc++/dist/libcxx/include/array +++ b/external/bsd/libc++/dist/libcxx/include/array @@ -224,7 +224,7 @@ array<_Tp, _Size>::at(size_type __n) const } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -232,7 +232,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -240,7 +240,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -248,7 +248,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -256,7 +256,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -264,7 +264,7 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -272,7 +272,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_swappable<_Tp>::value, @@ -307,7 +307,7 @@ public: }; template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT { @@ -316,7 +316,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT } template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT { @@ -327,7 +327,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT { diff --git a/external/bsd/libc++/dist/libcxx/include/chrono b/external/bsd/libc++/dist/libcxx/include/chrono index 9fb774317da..2c65eee7d06 100644 --- a/external/bsd/libc++/dist/libcxx/include/chrono +++ b/external/bsd/libc++/dist/libcxx/include/chrono @@ -409,6 +409,37 @@ class _LIBCPP_TYPE_VIS_ONLY duration static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(_Period::num > 0, "duration period must be positive"); + + template <class _R1, class _R2> + struct __no_overflow + { + private: + static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; + static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; + static const intmax_t __n1 = _R1::num / __gcd_n1_n2; + static const intmax_t __d1 = _R1::den / __gcd_d1_d2; + static const intmax_t __n2 = _R2::num / __gcd_n1_n2; + static const intmax_t __d2 = _R2::den / __gcd_d1_d2; + static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); + + template <intmax_t _Xp, intmax_t _Yp, bool __overflow> + struct __mul // __overflow == false + { + static const intmax_t value = _Xp * _Yp; + }; + + template <intmax_t _Xp, intmax_t _Yp> + struct __mul<_Xp, _Yp, true> + { + static const intmax_t value = 1; + }; + + public: + static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); + typedef ratio<__mul<__n1, __d2, !value>::value, + __mul<__n2, __d1, !value>::value> type; + }; + public: typedef _Rep rep; typedef _Period period; @@ -440,9 +471,10 @@ public: duration(const duration<_Rep2, _Period2>& __d, typename enable_if < + __no_overflow<_Period2, period>::value && ( treat_as_floating_point<rep>::value || - (ratio_divide<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value) + (__no_overflow<_Period2, period>::type::den == 1 && + !treat_as_floating_point<_Rep2>::value)) >::type* = 0) : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {} @@ -910,12 +942,9 @@ typedef steady_clock high_resolution_clock; } // chrono -#if _LIBCPP_STD_VER > 11 -// Literal suffixes for chrono types -// inline // Deviation from N3690. -// We believe the inline to be a defect and have submitted an LWG issue. -// An LWG issue number has not yet been assigned. -namespace literals +#if _LIBCPP_STD_VER > 11 +// Suffixes for duration literals [time.duration.literals] +inline namespace literals { inline namespace chrono_literals { @@ -986,6 +1015,11 @@ namespace literals } }} + +namespace chrono { // hoist the literals into namespace std::chrono + using namespace literals::chrono_literals; +} + #endif _LIBCPP_END_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/include/cmath b/external/bsd/libc++/dist/libcxx/include/cmath index f253b93442f..75087ae78fb 100644 --- a/external/bsd/libc++/dist/libcxx/include/cmath +++ b/external/bsd/libc++/dist/libcxx/include/cmath @@ -767,7 +767,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {ret #endif template <class _A1> -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY typename enable_if<is_integral<_A1>::value, double>::type cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} diff --git a/external/bsd/libc++/dist/libcxx/include/codecvt b/external/bsd/libc++/dist/libcxx/include/codecvt index 25f4a2e1e4c..6eff107cd1c 100644 --- a/external/bsd/libc++/dist/libcxx/include/codecvt +++ b/external/bsd/libc++/dist/libcxx/include/codecvt @@ -29,7 +29,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf8 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf8(size_t refs = 0); + ~codecvt_utf8(); }; template <class Elem, unsigned long Maxcode = 0x10ffff, @@ -37,7 +38,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf16 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf16(size_t refs = 0); + ~codecvt_utf16(); }; template <class Elem, unsigned long Maxcode = 0x10ffff, @@ -45,7 +47,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf8_utf16 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf8_utf16(size_t refs = 0); + ~codecvt_utf8_utf16(); }; } // std diff --git a/external/bsd/libc++/dist/libcxx/include/complex b/external/bsd/libc++/dist/libcxx/include/complex index e1d72f4d596..2943da1d775 100644 --- a/external/bsd/libc++/dist/libcxx/include/complex +++ b/external/bsd/libc++/dist/libcxx/include/complex @@ -1521,6 +1521,47 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) return __os << __s.str(); } +#if _LIBCPP_STD_VER > 11 +// Literal suffix for complex number literals [complex.literals] +inline namespace literals +{ + inline namespace complex_literals + { + constexpr complex<long double> operator""il(long double __im) + { + return { 0.0l, __im }; + } + + constexpr complex<long double> operator""il(unsigned long long __im) + { + return { 0.0l, static_cast<long double>(__im) }; + } + + + constexpr complex<double> operator""i(long double __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + constexpr complex<double> operator""i(unsigned long long __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + + constexpr complex<float> operator""if(long double __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + + constexpr complex<float> operator""if(unsigned long long __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + } +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_COMPLEX diff --git a/external/bsd/libc++/dist/libcxx/include/cstdio b/external/bsd/libc++/dist/libcxx/include/cstdio index 1cde3eee536..ce3af4d91dc 100644 --- a/external/bsd/libc++/dist/libcxx/include/cstdio +++ b/external/bsd/libc++/dist/libcxx/include/cstdio @@ -74,7 +74,7 @@ int fputc(int c, FILE* stream); int fputs(const char* restrict s, FILE* restrict stream); int getc(FILE* stream); int getchar(void); -char* gets(char* s); +char* gets(char* s); // removed in C++14 int putc(int c, FILE* stream); int putchar(int c); int puts(const char* s); @@ -103,6 +103,11 @@ void perror(const char* s); #pragma GCC system_header #endif +// snprintf +#if defined(_LIBCPP_MSVCRT) +#include "support/win32/support.h" +#endif + #ifdef getc inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);} #undef getc @@ -153,7 +158,9 @@ using ::fputc; using ::fputs; using ::getc; using ::getchar; +#if _LIBCPP_STD_VER <= 11 using ::gets; +#endif using ::putc; using ::putchar; using ::puts; diff --git a/external/bsd/libc++/dist/libcxx/include/cwchar b/external/bsd/libc++/dist/libcxx/include/cwchar index 90eae75e869..9f51587caa5 100644 --- a/external/bsd/libc++/dist/libcxx/include/cwchar +++ b/external/bsd/libc++/dist/libcxx/include/cwchar @@ -106,7 +106,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, #include <__config> #include <cwctype> #include <wchar.h> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/support.h> // pull in *swprintf defines #endif // _LIBCPP_MSVCRT diff --git a/external/bsd/libc++/dist/libcxx/include/deque b/external/bsd/libc++/dist/libcxx/include/deque index 4faa87f8b34..f099000b137 100644 --- a/external/bsd/libc++/dist/libcxx/include/deque +++ b/external/bsd/libc++/dist/libcxx/include/deque @@ -41,6 +41,7 @@ public: deque() noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit deque(const allocator_type& a); explicit deque(size_type n); + explicit deque(size_type n, const allocator_type& a); // C++14 deque(size_type n, const value_type& v); deque(size_type n, const value_type& v, const allocator_type& a); template <class InputIterator> @@ -1209,6 +1210,9 @@ public: {} _LIBCPP_INLINE_VISIBILITY deque(const allocator_type& __a) : __base(__a) {} explicit deque(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit deque(size_type __n, const _Allocator& __a); +#endif deque(size_type __n, const value_type& __v); deque(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIter> @@ -1431,6 +1435,16 @@ deque<_Tp, _Allocator>::deque(size_type __n) __append(__n); } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Allocator> +deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) + : __base(__a) +{ + if (__n > 0) + __append(__n); +} +#endif + template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) { @@ -2797,7 +2811,7 @@ deque<_Tp, _Allocator>::clear() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2806,7 +2820,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2814,7 +2828,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2822,7 +2836,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2830,7 +2844,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2838,7 +2852,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2846,7 +2860,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/external/bsd/libc++/dist/libcxx/include/dynarray b/external/bsd/libc++/dist/libcxx/include/dynarray new file mode 100644 index 00000000000..b0d04f91544 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/include/dynarray @@ -0,0 +1,311 @@ +// -*- C++ -*- +//===-------------------------- dynarray ----------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_DYNARRAY +#define _LIBCPP_DYNARRAY + +#include <__config> +#if _LIBCPP_STD_VER > 11 + +/* + dynarray synopsis + +namespace std { + +template< typename T > +class dynarray +{ + // types: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* pointer; + typedef const T* const_pointer; + typedef implementation-defined iterator; + typedef implementation-defined const_iterator; + typedef reverse_iterator<iterator> reverse_iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +public: + // construct/copy/destroy: + explicit dynarray(size_type c); + template <typename Alloc> + dynarray(size_type c, const Alloc& alloc); + dynarray(size_type c, const T& v); + template <typename Alloc> + dynarray(size_type c, const T& v, const Alloc& alloc); + dynarray(const dynarray& d); + template <typename Alloc> + dynarray(const dynarray& d, const Alloc& alloc); + dynarray(initializer_list<T>); + template <typename Alloc> + dynarray(initializer_list<T>, const Alloc& alloc); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + iterator begin() noexcept; + const_iterator begin() const noexcept; + const_iterator cbegin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; + const_iterator cend() const noexcept; + + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator crbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crend() const noexcept; + + // capacity: + size_type size() const noexcept; + size_type max_size() const noexcept; + bool empty() const noexcept; + + // element access: + reference operator[](size_type n); + const_reference operator[](size_type n) const; + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + const_reference at(size_type n) const; + reference at(size_type n); + + // data access: + T* data() noexcept; + const T* data() const noexcept; + + // mutating member functions: + void fill(const T& v); +}; + +} // std + +*/ + +#include <__functional_base> +#include <iterator> +#include <stdexcept> +#include <initializer_list> +#include <new> +#include <algorithm> + +#if defined(_LIBCPP_NO_EXCEPTIONS) + #include <cassert> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY dynarray +{ +public: + // types: + typedef dynarray __self; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + +private: + size_t __size_; + value_type * __base_; + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {} + + static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) + { + if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count ) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_length(); +#else + assert(!"dynarray::allocation"); +#endif + } + return static_cast<value_type *> (::operator new (sizeof(value_type) * count)); + } + + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + { + ::operator delete (static_cast<void *> (__ptr)); + } + +public: + + explicit dynarray(size_type __c); + dynarray(size_type __c, const value_type& __v); + dynarray(const dynarray& __d); + dynarray(initializer_list<value_type>); + +// We're not implementing these right now. +// Waiting for the resolution of LWG issue #2235 +// template <typename _Alloc> +// dynarray(size_type __c, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(const dynarray& __d, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(initializer_list<value_type>, const _Alloc& __alloc); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); } + + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } + + // capacity: + inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; } + + // element access: + inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; } + + inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; } + + inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const; + inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n); + + // data access: + inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; } + inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; } + + // mutating member functions: + inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); } +}; + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type (__v); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray () +{ + size_t sz = __il.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __il.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () +{ + size_t sz = __d.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __d.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::~dynarray() +{ + value_type *__data = data () + __size_; + for ( size_t i = 0; i < __size_; ++i ) + (--__data)->value_type::~value_type(); + __deallocate ( __base_ ); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::reference +dynarray<_Tp>::at(size_type __n) +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::const_reference +dynarray<_Tp>::at(size_type __n) const +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template <class _Tp, class _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<dynarray<_Tp>, _Alloc> : true_type {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // if _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_DYNARRAY diff --git a/external/bsd/libc++/dist/libcxx/include/ext/hash_map b/external/bsd/libc++/dist/libcxx/include/ext/hash_map index 3e474b02e7d..225b72baa2c 100644 --- a/external/bsd/libc++/dist/libcxx/include/ext/hash_map +++ b/external/bsd/libc++/dist/libcxx/include/ext/hash_map @@ -206,7 +206,11 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <ext/__hash> #if __DEPRECATED -#warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") +#else +# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> +#endif #endif #pragma GCC system_header @@ -684,7 +688,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> diff --git a/external/bsd/libc++/dist/libcxx/include/ext/hash_set b/external/bsd/libc++/dist/libcxx/include/ext/hash_set index deffcb61b06..c4bb89843d5 100644 --- a/external/bsd/libc++/dist/libcxx/include/ext/hash_set +++ b/external/bsd/libc++/dist/libcxx/include/ext/hash_set @@ -199,7 +199,11 @@ template <class Value, class Hash, class Pred, class Alloc> #include <ext/__hash> #if __DEPRECATED -#warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>") +#else +# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> +#endif #endif namespace __gnu_cxx { diff --git a/external/bsd/libc++/dist/libcxx/include/forward_list b/external/bsd/libc++/dist/libcxx/include/forward_list index a524f2ced69..398226b8d42 100644 --- a/external/bsd/libc++/dist/libcxx/include/forward_list +++ b/external/bsd/libc++/dist/libcxx/include/forward_list @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit forward_list(const allocator_type& a); explicit forward_list(size_type n); + explicit forward_list(size_type n, const allocator_type& a); // C++14 forward_list(size_type n, const value_type& v); forward_list(size_type n, const value_type& v, const allocator_type& a); template <class InputIterator> @@ -571,6 +572,9 @@ public: {} // = default; explicit forward_list(const allocator_type& __a); explicit forward_list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit forward_list(size_type __n, const allocator_type& __a); +#endif forward_list(size_type __n, const value_type& __v); forward_list(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIterator> @@ -794,6 +798,28 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Alloc> +forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) + : base ( __a ) +{ + if (__n > 0) + { + __node_allocator& __a = base::__alloc(); + typedef __allocator_destructor<__node_allocator> _Dp; + unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); + for (__node_pointer __p = base::__before_begin(); __n > 0; --__n, + __p = __p->__next_) + { + __h.reset(__node_traits::allocate(__a, 1)); + __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); + __h->__next_ = nullptr; + __p->__next_ = __h.release(); + } + } +} +#endif + template <class _Tp, class _Alloc> forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { diff --git a/external/bsd/libc++/dist/libcxx/include/functional b/external/bsd/libc++/dist/libcxx/include/functional index 1486a8e0475..d40f70af40b 100644 --- a/external/bsd/libc++/dist/libcxx/include/functional +++ b/external/bsd/libc++/dist/libcxx/include/functional @@ -56,7 +56,7 @@ public: // invoke template <class... ArgTypes> - typename result_of<T(ArgTypes...)>::type + typename result_of<T&(ArgTypes&&...)>::type operator() (ArgTypes&&...) const; }; @@ -358,18 +358,6 @@ template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S ( template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); template<class R, class T> unspecified mem_fn(R T::*); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...)); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &&); class bad_function_call : public exception @@ -504,7 +492,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; @@ -513,7 +502,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY plus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; @@ -527,7 +517,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; @@ -536,7 +527,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY minus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; @@ -550,7 +542,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; @@ -559,7 +552,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY multiplies<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; @@ -573,7 +567,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; @@ -582,7 +577,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY divides<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; @@ -596,7 +592,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; @@ -605,7 +602,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY modulus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; @@ -619,7 +617,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const {return -__x;} }; @@ -628,7 +627,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY negate<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return -_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; @@ -642,7 +642,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; @@ -650,7 +651,8 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY equal_to<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -665,7 +667,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; @@ -673,7 +676,8 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -688,7 +692,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; @@ -696,7 +701,8 @@ struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY greater<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -713,7 +719,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; @@ -721,7 +728,8 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -736,7 +744,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; @@ -744,7 +753,8 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY less_equal<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -759,7 +769,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; @@ -767,7 +778,8 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY logical_and<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -782,7 +794,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; @@ -790,7 +803,8 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TYPE_VIS_ONLY logical_or<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -805,7 +819,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x) const {return !__x;} }; @@ -814,7 +829,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY logical_not<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return !_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; @@ -828,7 +844,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; @@ -836,7 +853,8 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> template <> struct _LIBCPP_TYPE_VIS_ONLY bit_and<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -851,7 +869,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; @@ -859,7 +878,8 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> template <> struct _LIBCPP_TYPE_VIS_ONLY bit_or<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -874,7 +894,8 @@ template <class _Tp> #endif struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; @@ -882,7 +903,8 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> template <> struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } typedef void is_transparent; @@ -894,7 +916,8 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void> template <class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const {return ~__x;} }; @@ -902,7 +925,8 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY bit_not<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return ~_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; @@ -914,14 +938,16 @@ class _LIBCPP_TYPE_VIS_ONLY unary_negate { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + explicit unary_negate(const _Predicate& __pred) : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::argument_type& __x) const {return !__pred_(__x);} }; template <class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} @@ -933,15 +959,17 @@ class _LIBCPP_TYPE_VIS_ONLY binary_negate { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred) - : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 + binary_negate(const _Predicate& __pred) : __pred_(__pred) {} + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {return !__pred_(__x, __y);} }; template <class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} @@ -1207,38 +1235,6 @@ mem_fn(_Rp _Tp::* __pm) return __mem_fn<_Rp _Tp::*>(__pm); } -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...)> -mem_fn(_Rp (_Tp::* __pm)(_Args...)) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm); -} - // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -2399,6 +2395,22 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double> } }; +#if _LIBCPP_STD_VER > 11 +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function<_Tp, size_t> +{ + static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); + + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + typedef typename underlying_type<_Tp>::type type; + return hash<type>{}(static_cast<type>(__v)); + } +}; +#endif + // struct hash<T*> in <memory> _LIBCPP_END_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/include/future b/external/bsd/libc++/dist/libcxx/include/future index b249464e431..73d5456d717 100644 --- a/external/bsd/libc++/dist/libcxx/include/future +++ b/external/bsd/libc++/dist/libcxx/include/future @@ -19,10 +19,10 @@ namespace std enum class future_errc { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; enum class launch @@ -309,11 +309,11 @@ public: }; template <class F, class... Args> - future<typename result_of<F(Args...)>::type> + future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type> async(F&& f, Args&&... args); template <class F, class... Args> - future<typename result_of<F(Args...)>::type> + future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type> async(launch policy, F&& f, Args&&... args); template <class> class packaged_task; // undefined @@ -379,10 +379,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc _LIBCPP_DECLARE_STRONG_ENUM(future_errc) { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) @@ -542,14 +542,14 @@ public: __state_ |= __future_attached; } _LIBCPP_INLINE_VISIBILITY - bool __has_future_attached() const {return __state_ & __future_attached;} + bool __has_future_attached() const {return (__state_ & __future_attached) != 0;} _LIBCPP_INLINE_VISIBILITY void __set_deferred() {__state_ |= deferred;} void __make_ready(); _LIBCPP_INLINE_VISIBILITY - bool __is_ready() const {return __state_ & ready;} + bool __is_ready() const {return (__state_ & ready) != 0;} void set_value(); void set_value_at_thread_exit(); @@ -2013,10 +2013,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template <class _Fp> + template <class _Fp, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template <class _Fp, class _Allocator> + template <class _Fp, class _Allocator, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2128,10 +2144,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template <class _Fp> + template <class _Fp, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template <class _Fp, class _Allocator> + template <class _Fp, class _Allocator, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2299,20 +2331,32 @@ private: } }; +inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value ) +{ return (int(__policy) & int(__value)) != 0; } + template <class _Fp, class... _Args> future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func<typename decay<_Fp>::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; - future<_Rp> __r; - if (int(__policy) & int(launch::async)) - __r = _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), + +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif + if (__does_policy_contain(__policy, launch::async)) + return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - else if (int(__policy) & int(launch::deferred)) - __r = _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch ( ... ) { if (__policy == launch::async) throw ; } +#endif + + if (__does_policy_contain(__policy, launch::deferred)) + return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - return __r; + return future<_Rp>{}; } template <class _Fp, class... _Args> diff --git a/external/bsd/libc++/dist/libcxx/include/initializer_list b/external/bsd/libc++/dist/libcxx/include/initializer_list index cdcd6881679..663e49b6ee4 100644 --- a/external/bsd/libc++/dist/libcxx/include/initializer_list +++ b/external/bsd/libc++/dist/libcxx/include/initializer_list @@ -29,15 +29,15 @@ public: typedef const E* iterator; typedef const E* const_iterator; - initializer_list() noexcept; + initializer_list() noexcept; // constexpr in C++14 - size_t size() const noexcept; - const E* begin() const noexcept; - const E* end() const noexcept; + size_t size() const noexcept; // constexpr in C++14 + const E* begin() const noexcept; // constexpr in C++14 + const E* end() const noexcept; // constexpr in C++14 }; -template<class E> const E* begin(initializer_list<E> il) noexcept; -template<class E> const E* end(initializer_list<E> il) noexcept; +template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14 +template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14 } // std @@ -62,6 +62,7 @@ class _LIBCPP_TYPE_VIS_ONLY initializer_list size_t __size_; _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT : __begin_(__b), __size_(__s) @@ -75,15 +76,26 @@ public: typedef const _Ep* iterator; typedef const _Ep* const_iterator; - _LIBCPP_ALWAYS_INLINE initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} - _LIBCPP_ALWAYS_INLINE size_t size() const _NOEXCEPT {return __size_;} - _LIBCPP_ALWAYS_INLINE const _Ep* begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_ALWAYS_INLINE const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + size_t size() const _NOEXCEPT {return __size_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* begin() const _NOEXCEPT {return __begin_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} }; template<class _Ep> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT { @@ -92,6 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT template<class _Ep> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT { diff --git a/external/bsd/libc++/dist/libcxx/include/iomanip b/external/bsd/libc++/dist/libcxx/include/iomanip index 0c58e1980f3..cdb0d5f0dbf 100644 --- a/external/bsd/libc++/dist/libcxx/include/iomanip +++ b/external/bsd/libc++/dist/libcxx/include/iomanip @@ -26,6 +26,17 @@ template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = template <class charT> T9 get_time(struct tm* tmb, const charT* fmt); template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt); +template <class charT> + T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template <class charT, class traits, class Allocator> + T12 quoted(const basic_string<charT, traits, Allocator>& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template <class charT, class traits, class Allocator> + T13 quoted(basic_string<charT, traits, Allocator>& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + } // std */ @@ -499,6 +510,142 @@ put_time(const tm* __tm, const _CharT* __fmt) return __iom_t10<_CharT>(__tm, __fmt); } +#if _LIBCPP_STD_VER > 11 + +template <class _CharT, class _Traits, class _ForwardIterator> +std::basic_ostream<_CharT, _Traits> & +__quoted_output ( basic_ostream<_CharT, _Traits> &__os, + _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) +{ + __os << __delim; + for ( ; __first != __last; ++ __first ) + { + if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) + __os << __escape; + __os << *__first; + } + __os << __delim; + return __os; +} + +template <class _CharT, class _Traits, class _String> +basic_istream<_CharT, _Traits> & +__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) +{ + __string.clear (); + _CharT __c; + __is >> __c; + if ( __is.fail ()) + return __is; + + if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string + { + __is.unget (); + __is >> __string; + return __is; + } + + __save_flags<_CharT, _Traits> sf(__is); + noskipws (__is); + while (true) + { + __is >> __c; + if ( __is.fail ()) + break; + if (_Traits::eq (__c, __escape)) + { + __is >> __c; + if ( __is.fail ()) + break; + } + else if (_Traits::eq (__c, __delim)) + break; + __string.push_back ( __c ); + } + return __is; +} + + +template <class _CharT, class _Iter, class _Traits=char_traits<_CharT>> +struct __quoted_output_proxy +{ + _Iter __first; + _Iter __last; + _CharT __delim; + _CharT __escape; + + __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) + : __first(__f), __last(__l), __delim(__d), __escape(__e) {} + // This would be a nice place for a string_ref +}; + +template <class _CharT, class _Traits, class _Iter> +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) +{ + return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); +} + +template <class _CharT, class _Traits, class _Allocator> +struct __quoted_proxy +{ + basic_string<_CharT, _Traits, _Allocator> &__string; + _CharT __delim; + _CharT __escape; + + __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) + : __string(__s), __delim(__d), __escape(__e) {} +}; + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_output (__os, __proxy.string.cbegin (), __proxy.string.cend (), __proxy.__delim, __proxy.__escape); +} + +// extractor for non-const basic_string& proxies +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +basic_istream<_CharT, _Traits>& operator>>( + basic_istream<_CharT, _Traits>& __is, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); +} + + +template <class _CharT> +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, const _CharT *> +quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) +{ + const _CharT *__end = __s; + while ( *__end ) ++__end; + return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); +} + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> +quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_output_proxy<_CharT, + typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> + ( __s.cbegin(), __s.cend (), __delim, __escape ); +} + +template <class _CharT, class _Traits, class _Allocator> +__quoted_proxy<_CharT, _Traits, _Allocator> +quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOMANIP diff --git a/external/bsd/libc++/dist/libcxx/include/ios b/external/bsd/libc++/dist/libcxx/include/ios index f3d4840278f..d95f18a5e1e 100644 --- a/external/bsd/libc++/dist/libcxx/include/ios +++ b/external/bsd/libc++/dist/libcxx/include/ios @@ -203,9 +203,9 @@ enum class io_errc }; concept_map ErrorCodeEnum<io_errc> { }; -error_code make_error_code(io_errc e); -error_condition make_error_condition(io_errc e); -storage-class-specifier const error_category& iostream_category; +error_code make_error_code(io_errc e) noexcept; +error_condition make_error_condition(io_errc e) noexcept; +storage-class-specifier const error_category& iostream_category() noexcept; } // std @@ -216,6 +216,10 @@ storage-class-specifier const error_category& iostream_category; #include <__locale> #include <system_error> +#if __has_feature(cxx_atomic) +#include <atomic> // for __xindex_ +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -319,7 +323,7 @@ public: _LIBCPP_INLINE_VISIBILITY bool bad() const; _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; - _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except); + _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); void __set_badbit_and_consider_rethrow(); void __set_failbit_and_consider_rethrow(); @@ -363,7 +367,11 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; +#if __has_feature(cxx_atomic) + static atomic<int> __xindex_; +#else static int __xindex_; +#endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; @@ -388,18 +396,18 @@ struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_typ #endif _LIBCPP_FUNC_VIS -const error_category& iostream_category(); +const error_category& iostream_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code -make_error_code(io_errc __e) +make_error_code(io_errc __e) _NOEXCEPT { return error_code(static_cast<int>(__e), iostream_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition -make_error_condition(io_errc __e) +make_error_condition(io_errc __e) _NOEXCEPT { return error_condition(static_cast<int>(__e), iostream_category()); } @@ -527,21 +535,21 @@ inline _LIBCPP_INLINE_VISIBILITY bool ios_base::eof() const { - return __rdstate_ & eofbit; + return (__rdstate_ & eofbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::fail() const { - return __rdstate_ & (failbit | badbit); + return (__rdstate_ & (failbit | badbit)) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::bad() const { - return __rdstate_ & badbit; + return (__rdstate_ & badbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY @@ -553,9 +561,9 @@ ios_base::exceptions() const inline _LIBCPP_INLINE_VISIBILITY void -ios_base::exceptions(iostate __except) +ios_base::exceptions(iostate __iostate) { - __exceptions_ = __except; + __exceptions_ = __iostate; clear(__rdstate_); } @@ -585,7 +593,7 @@ public: _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} - _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} + _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} // 27.5.4.1 Constructor/destructor: _LIBCPP_INLINE_VISIBILITY diff --git a/external/bsd/libc++/dist/libcxx/include/istream b/external/bsd/libc++/dist/libcxx/include/istream index 7284fc1fee0..14fa466057c 100644 --- a/external/bsd/libc++/dist/libcxx/include/istream +++ b/external/bsd/libc++/dist/libcxx/include/istream @@ -1369,8 +1369,10 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos) this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) + { if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -1391,7 +1393,10 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) + this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) diff --git a/external/bsd/libc++/dist/libcxx/include/iterator b/external/bsd/libc++/dist/libcxx/include/iterator index 87d6d1d2144..d16aa2aa95f 100644 --- a/external/bsd/libc++/dist/libcxx/include/iterator +++ b/external/bsd/libc++/dist/libcxx/include/iterator @@ -309,6 +309,19 @@ template <class C> auto end(const C& c) -> decltype(c.end()); template <class T, size_t N> T* begin(T (&array)[N]); template <class T, size_t N> T* end(T (&array)[N]); +template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14 +template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14 +template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14 +template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14 +template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 +template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14 +template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14 + } // std */ @@ -317,11 +330,12 @@ template <class T, size_t N> T* end(T (&array)[N]); #include <type_traits> #include <cstddef> #include <iosfwd> +#include <initializer_list> #ifdef __APPLE__ #include <Availability.h> #endif -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -1016,7 +1030,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY move_iterator<_Iter> -make_move_iterator(const _Iter& __i) +make_move_iterator(_Iter __i) { return move_iterator<_Iter>(__i); } @@ -1197,12 +1211,13 @@ public: _LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT {return __i;} private: - _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x) { __get_db()->__insert_ic(this, __p); } +#else + _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #endif template <class _Up> friend class __wrap_iter; @@ -1370,456 +1385,101 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } -#ifdef _LIBCPP_DEBUG - -// __debug_iter - -template <class _Container, class _Iter> class __debug_iter; - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter> -_LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&); - -template <class _Container, class _Iter> -class __debug_iter -{ -public: - typedef _Iter iterator_type; - typedef _Container __container_type; - typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef typename iterator_traits<iterator_type>::pointer pointer; - typedef typename iterator_traits<iterator_type>::reference reference; -private: - iterator_type __i; - __debug_iter* __next; - __container_type* __cont; - -public: - _LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {} - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x) - : __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);} - __debug_iter& operator=(const __debug_iter& __x); - template <class _Up> _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) - : __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);} - _LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int) - {__debug_iter __tmp(*this); operator++(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int) - {__debug_iter __tmp(*this); operator--(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const - {__debug_iter __t(*this); __t += __n; return __t;} - __debug_iter& operator+=(difference_type __n); - _LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const - {__debug_iter __t(*this); __t -= __n; return __t;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n) - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return *(*this + __n);} - -private: - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x) - : __i(__x), __next(0), __cont(0) {__set_owner(__c);} - _LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;} - - void __set_owner(const __container_type* __c); - void __remove_owner(); - static void __remove_all(__container_type* __c); - static void swap(__container_type* __x, __container_type* __y); - - _LIBCPP_INLINE_VISIBILITY bool __is_deref() const - {return __is_deref(__is_random_access_iterator<iterator_type>());} - bool __is_deref(false_type) const; - bool __is_deref(true_type) const; - _LIBCPP_INLINE_VISIBILITY bool __can_decrement() const - {return __can_decrement(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_decrement(integral_constant<int, 0>) const; - bool __can_decrement(integral_constant<int, 1>) const; - bool __can_decrement(integral_constant<int, 2>) const; - _LIBCPP_INLINE_VISIBILITY bool __can_increment() const - {return __can_increment(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_increment(integral_constant<int, 0>) const; - bool __can_increment(integral_constant<int, 1>) const; - bool __can_increment(integral_constant<int, 2>) const; - - _LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const - {return __can_add(__n, is_pointer<iterator_type>());} - bool __can_add(difference_type __n, false_type) const; - bool __can_add(difference_type __n, true_type) const; - - template <class _Cp, class _Up> friend class __debug_iter; - friend class _Container::__self; - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - typename __debug_iter<_Cp, _Iter1>::difference_type - operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1> - friend - __debug_iter<_Cp, _Iter1> - operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&); -}; - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x) -{ - if (this != &__x) - { - __remove_owner(); - __i = __x.__i; - __set_owner(__x.__cont); - } - return *this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c) -{ - __cont = const_cast<__container_type*>(__c); - __debug_iter*& __head = __cont->__get_iterator_list(this); - __next = __head; - __head = this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_owner() -{ - if (__cont) - { - __debug_iter*& __head = __cont->__get_iterator_list(this); - if (__head == this) - __head = __next; - else - { - __debug_iter* __prev = __head; - for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next) - __prev = __p; - __prev->__next = __next; - } - __cont = 0; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c) -{ - __debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head; - __head = 0; - while (__p) - { - __p->__cont = 0; - __debug_iter* __n = __p->__next; - __p->__next = 0; - __p = __n; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y) -{ - __debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0); - __debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head_x; - __head_x = __head_y; - __head_y = __p; - for (__p = __head_x; __p; __p = __p->__next) - __p->__cont = __x; - for (__p = __head_y; __p; __p = __p->__next) - __p->__cont = __y; -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(false_type) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(true_type) const -{ - if (__cont == 0) - return false; - return __i < __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->begin().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator+=(difference_type __n) -{ - assert(__can_add(__n)); - __i += __n; - return *this; -} +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(_Cp& __c) -> decltype(__c.begin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() == __y.base(); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(const _Cp& __c) -> decltype(__c.begin()) { - return !(__x == __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(_Cp& __c) -> decltype(__c.end()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() < __y.base(); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(const _Cp& __c) -> decltype(__c.end()) { - return __y < __x; + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +#if _LIBCPP_STD_VER > 11 + +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cbegin(const _Cp& __c) -> decltype(begin(__c)) { - return !(__x < __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cend(const _Cp& __c) -> decltype(end(__c)) { - return !(__y < __x); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() - __y.base(); + return __c.rbegin(); } -template <class _Container, class _Iter> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, - const __debug_iter<_Container, _Iter>& __x) +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { - return __x + __n; + return __c.rbegin(); } -#endif // _LIBCPP_DEBUG - -#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) - template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(_Cp& __c) -> decltype(__c.begin()) +auto rend(_Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(const _Cp& __c) -> decltype(__c.begin()) +auto rend(const _Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(_Cp& __c) -> decltype(__c.end()) +auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) { - return __c.end(); + return rbegin(__c); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(const _Cp& __c) -> decltype(__c.end()) +auto crend(const _Cp& __c) -> decltype(rend(__c)) { - return __c.end(); + return rend(__c); } +#endif + + #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> @@ -1872,6 +1532,37 @@ end(_Tp (&__array)[_Np]) return __array + _Np; } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array + _Np); +} + +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.end()); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.begin()); +} + +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ITERATOR diff --git a/external/bsd/libc++/dist/libcxx/include/list b/external/bsd/libc++/dist/libcxx/include/list index 92b7724cc92..800a1a3f5aa 100644 --- a/external/bsd/libc++/dist/libcxx/include/list +++ b/external/bsd/libc++/dist/libcxx/include/list @@ -40,6 +40,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit list(const allocator_type& a); explicit list(size_type n); + explicit list(size_type n, const allocator_type& a); // C++14 list(size_type n, const value_type& value); list(size_type n, const value_type& value, const allocator_type& a); template <class Iter> @@ -178,7 +179,7 @@ template <class T, class Alloc> #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -842,13 +843,16 @@ public: #endif } _LIBCPP_INLINE_VISIBILITY - list(const allocator_type& __a) : base(__a) + explicit list(const allocator_type& __a) : base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } - list(size_type __n); + explicit list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit list(size_type __n, const allocator_type& __a); +#endif list(size_type __n, const value_type& __x); list(size_type __n, const value_type& __x, const allocator_type& __a); template <class _InpIter> @@ -1100,6 +1104,22 @@ list<_Tp, _Alloc>::list(size_type __n) #endif } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Alloc> +list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + for (; __n > 0; --__n) +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + emplace_back(); +#else + push_back(value_type()); +#endif +} +#endif + template <class _Tp, class _Alloc> list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { diff --git a/external/bsd/libc++/dist/libcxx/include/locale b/external/bsd/libc++/dist/libcxx/include/locale index 8877192e56b..d13d49e6466 100644 --- a/external/bsd/libc++/dist/libcxx/include/locale +++ b/external/bsd/libc++/dist/libcxx/include/locale @@ -93,10 +93,12 @@ public: typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - wstring_convert(Codecvt* pcvt = new Codecvt); + explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 wstring_convert(Codecvt* pcvt, state_type state); - wstring_convert(const byte_string& byte_err, + explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); + wstring_convert(const wstring_convert&) = delete; // C++14 + wstring_convert & operator=(const wstring_convert &) = delete; // C++14 ~wstring_convert(); wide_string from_bytes(char byte); @@ -109,7 +111,7 @@ public: byte_string to_bytes(const wide_string& wstr); byte_string to_bytes(const Elem* first, const Elem* last); - size_t converted() const; + size_t converted() const; // noexcept in C++14 state_type state() const; }; @@ -120,9 +122,12 @@ class wbuffer_convert public: typedef typename Tr::state_type state_type; - wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, - state_type state = state_type()); - + explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // explicit in C++14 + wbuffer_convert(const wbuffer_convert&) = delete; // C++14 + wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 + ~wbuffer_convert(); // C++14 + streambuf* rdbuf() const; streambuf* rdbuf(streambuf* bytebuf); @@ -186,7 +191,7 @@ template <class charT> class messages_byname; #endif #include <cstdlib> #include <ctime> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> #else // _LIBCPP_MSVCRT #include <nl_types.h> @@ -234,7 +239,7 @@ __mb_cur_max_l(locale_t __l) return MB_CUR_MAX_L(__l); } #else // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) { __locale_raii __current(uselocale(__l), uselocale); @@ -242,7 +247,7 @@ decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) } #endif // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE wint_t __btowc_l(int __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -253,7 +258,7 @@ wint_t __btowc_l(int __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __wctob_l(wint_t __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -264,7 +269,7 @@ int __wctob_l(wint_t __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -276,7 +281,7 @@ size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -287,7 +292,7 @@ size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -299,7 +304,7 @@ size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { @@ -311,7 +316,7 @@ size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -322,7 +327,7 @@ int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -333,7 +338,7 @@ size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE lconv *__localeconv_l(locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -344,7 +349,7 @@ lconv *__localeconv_l(locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -687,8 +692,8 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex return 0; } -_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_TYPE_VIS __num_get<char>) -_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY num_get @@ -786,26 +791,61 @@ protected: _LIBCPP_ALWAYS_INLINE ~num_get() {} + template <class _Fp> + iter_type __do_get_floating_point + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Fp& __v) const; + + template <class _Signed> + iter_type __do_get_signed + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Signed& __v) const; + + template <class _Unsigned> + iter_type __do_get_unsigned + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Unsigned& __v) const; + + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long& __v) const; + ios_base::iostate& __err, long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long long& __v) const; + ios_base::iostate& __err, long long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned short& __v) const; + ios_base::iostate& __err, unsigned short& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned int& __v) const; + ios_base::iostate& __err, unsigned int& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long& __v) const; + ios_base::iostate& __err, unsigned long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long long& __v) const; + ios_base::iostate& __err, unsigned long long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, float& __v) const; + ios_base::iostate& __err, float& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, double& __v) const; + ios_base::iostate& __err, double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long double& __v) const; + ios_base::iostate& __err, long double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; }; @@ -947,153 +987,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral<long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral<long long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned short& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral<unsigned short>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// signed template <class _CharT, class _InputIterator> +template <class _Signed> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned int& __v) const + _Signed& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1126,7 +1028,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral<unsigned int>(__a, __a_end, __err, __base); + __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1135,59 +1037,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral<unsigned long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// unsigned template <class _CharT, class _InputIterator> +template <class _Unsigned> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned long long& __v) const + _Unsigned& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1220,59 +1078,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral<unsigned long long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - float& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float<float>(__a, __a_end, __err); + __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1281,64 +1087,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - double& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float<double>(__a, __a_end, __err); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// floating point template <class _CharT, class _InputIterator> +template <class _Fp> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - long double& __v) const + _Fp& __v) const { // Stage 1, nothing to do // Stage 2 @@ -1376,7 +1133,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_float<long double>(__a, __a_end, __err); + __v = __num_get_float<_Fp>(__a, __a_end, __err); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1436,8 +1193,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS num_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>) struct _LIBCPP_TYPE_VIS __num_put_base { @@ -1586,8 +1343,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, __op = __ob + (__np - __nb); } -_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_TYPE_VIS __num_put<char>) -_LIBCPP_EXTERN_TEMPLATE(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY num_put @@ -1770,7 +1527,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return do_put(__s, __iob, __fl, (unsigned long)__v); const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc()); typedef typename numpunct<char_type>::string_type string_type; +#if _LIBCPP_DEBUG_LEVEL >= 2 + string_type __tmp(__v ? __np.truename() : __np.falsename()); + string_type __nm = _VSTD::move(__tmp); +#else string_type __nm = __v ? __np.truename() : __np.falsename(); +#endif for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) *__s = *__i; return __s; @@ -2066,8 +1828,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS num_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>) template <class _CharT, class _InputIterator> _LIBCPP_HIDDEN @@ -2733,8 +2495,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>) class _LIBCPP_TYPE_VIS __time_get { @@ -2816,8 +2578,8 @@ private: virtual const string_type& __X() const {return this->__X_;} }; -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_get_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>) class _LIBCPP_TYPE_VIS __time_put { @@ -2929,8 +2691,8 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, return _VSTD::copy(__nb, __ne, __s); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY time_put_byname @@ -2950,8 +2712,8 @@ protected: ~time_put_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_put_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>) // money_base @@ -3017,10 +2779,10 @@ template <class _CharT, bool _International> const bool moneypunct<_CharT, _International>::intl; -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct<char, false>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct<char, true>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>) // moneypunct_byname @@ -3074,10 +2836,10 @@ template<> void moneypunct_byname<char, true>::init(const char*); template<> void moneypunct_byname<wchar_t, false>::init(const char*); template<> void moneypunct_byname<wchar_t, true>::init(const char*); -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>) // money_get @@ -3133,8 +2895,8 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, } } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __money_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY money_get @@ -3321,7 +3083,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, bool __more_needed = __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none)); - bool __sb = __flags & ios_base::showbase; + bool __sb = (__flags & ios_base::showbase) != 0; if (__sb || __more_needed) { typename string_type::const_iterator __sym_space_end = __sym.begin(); @@ -3514,8 +3276,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS money_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>) // money_put @@ -3689,8 +3451,8 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m __mi = __mb; } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __money_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY money_put @@ -3846,8 +3608,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS money_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>) // messages @@ -3956,8 +3718,8 @@ messages<_CharT>::do_close(catalog __c) const #endif // !_WIN32 } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS messages<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS messages<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>) template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY messages_byname @@ -3980,8 +3742,8 @@ protected: ~messages_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS messages_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>) template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, @@ -4004,9 +3766,9 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: - wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); wstring_convert(_Codecvt* __pcvt, state_type __state); - wstring_convert(const byte_string& __byte_err, + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES wstring_convert(wstring_convert&& __wc); @@ -4036,7 +3798,7 @@ public: byte_string to_bytes(const _Elem* __first, const _Elem* __last); _LIBCPP_ALWAYS_INLINE - size_t converted() const {return __cvtcount_;} + size_t converted() const _NOEXCEPT {return __cvtcount_;} _LIBCPP_ALWAYS_INLINE state_type state() const {return __cvtstate_;} }; @@ -4270,8 +4032,8 @@ private: wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); public: - wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, - state_type __state = state_type()); + _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, + _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY diff --git a/external/bsd/libc++/dist/libcxx/include/map b/external/bsd/libc++/dist/libcxx/include/map index 6a80af5dae9..009e8e2162c 100644 --- a/external/bsd/libc++/dist/libcxx/include/map +++ b/external/bsd/libc++/dist/libcxx/include/map @@ -77,7 +77,12 @@ public: map(map&& m, const allocator_type& a); map(initializer_list<value_type> il, const key_compare& comp = key_compare()); map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); - ~map(); + template <class InputIterator> + map(InputIterator first, InputIterator last, const allocator_type& a) + : map(first, last, Compare(), a) {} // C++14 + map(initializer_list<value_type> il, const allocator_type& a) + : map(il, Compare(), a) {} // C++14 + ~map(); map& operator=(const map& m); map& operator=(map&& m) @@ -273,6 +278,11 @@ public: multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); + template <class InputIterator> + multimap(InputIterator first, InputIterator last, const allocator_type& a) + : multimap(first, last, Compare(), a) {} // C++14 + multimap(initializer_list<value_type> il, const allocator_type& a) + : multimap(il, Compare(), a) {} // C++14 ~multimap(); multimap& operator=(const multimap& m); @@ -565,6 +575,75 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> class multimap; template <class _TreeIterator> class __map_const_iterator; +#if __cplusplus >= 201103L + +template <class _Key, class _Tp> +union __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + typedef pair<key_type, mapped_type> __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template <class ..._Args> + _LIBCPP_INLINE_VISIBILITY + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(const __value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__value_type() {__cc.~value_type();} +}; + +#else + +template <class _Key, class _Tp> +struct __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __value_type() {} + + template <class _A0> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template <class _A0, class _A1> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_iterator { @@ -730,49 +809,7 @@ public: private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename map::value_type value_type; - typedef typename map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename map::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -827,6 +864,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : map(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map(const map& __m) : __tree_(__m.__tree_) @@ -885,6 +929,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + map(initializer_list<value_type> __il, const allocator_type& __a) + : map(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map& operator=(initializer_list<value_type> __il) { @@ -1266,7 +1316,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1300,7 +1350,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Compare, class _Allocator> @@ -1489,49 +1539,8 @@ public: }; private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename multimap::value_type value_type; - typedef typename multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename multimap::value_type value_type; - value_type __cc; - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -1586,6 +1595,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multimap(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap(const multimap& __m) : __tree_(__m.__tree_.value_comp(), @@ -1645,6 +1661,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multimap(initializer_list<value_type> __il, const allocator_type& __a) + : multimap(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap& operator=(initializer_list<value_type> __il) { diff --git a/external/bsd/libc++/dist/libcxx/include/memory b/external/bsd/libc++/dist/libcxx/include/memory index 49a53c32dc4..bf44837fc2a 100644 --- a/external/bsd/libc++/dist/libcxx/include/memory +++ b/external/bsd/libc++/dist/libcxx/include/memory @@ -90,7 +90,7 @@ struct allocator_traits template <class T> static void destroy(allocator_type& a, T* p); - static size_type max_size(const allocator_type& a); + static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); @@ -496,8 +496,8 @@ public: long use_count() const noexcept; bool expired() const noexcept; shared_ptr<T> lock() const noexcept; - template<class U> bool owner_before(shared_ptr<U> const& b); - template<class U> bool owner_before(weak_ptr<U> const& b); + template<class U> bool owner_before(shared_ptr<U> const& b) const; + template<class U> bool owner_before(weak_ptr<U> const& b) const; }; // weak_ptr specialized algorithms: @@ -917,13 +917,13 @@ public: namespace __has_pointer_type_imp { - template <class _Up> static __two test(...); - template <class _Up> static char test(typename _Up::pointer* = 0); + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::pointer* = 0); } template <class _Tp> struct __has_pointer_type - : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> + : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1> { }; @@ -1483,7 +1483,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} _LIBCPP_INLINE_VISIBILITY - static size_type max_size(const allocator_type& __a) + static size_type max_size(const allocator_type& __a) _NOEXCEPT {return __max_size(__has_max_size<const allocator_type>(), __a);} _LIBCPP_INLINE_VISIBILITY @@ -3895,8 +3895,8 @@ public: < !is_array<_Yp>::value && is_convertible<_Yp*, element_type*>::value, - shared_ptr& - >::type + shared_ptr + >::type& operator=(auto_ptr<_Yp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> @@ -4522,8 +4522,8 @@ typename enable_if < !is_array<_Yp>::value && is_convertible<_Yp*, _Tp*>::value, - shared_ptr<_Tp>& ->::type + shared_ptr<_Tp> +>::type& shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) { shared_ptr(_VSTD::move(__r)).swap(*this); diff --git a/external/bsd/libc++/dist/libcxx/include/new b/external/bsd/libc++/dist/libcxx/include/new index 94a284958bb..ea4a4a01a99 100644 --- a/external/bsd/libc++/dist/libcxx/include/new +++ b/external/bsd/libc++/dist/libcxx/include/new @@ -27,6 +27,18 @@ public: virtual const char* what() const noexcept; }; +class bad_array_length : public bad_alloc // C++14 +{ +public: + bad_array_length() noexcept; +}; + +class bad_array_new_length : public bad_alloc +{ +public: + bad_array_new_length() noexcept; +}; + struct nothrow_t {}; extern const nothrow_t nothrow; typedef void (*new_handler)(); @@ -81,6 +93,21 @@ public: virtual const char* what() const _NOEXCEPT; }; +#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) + +class _LIBCPP_EXCEPTION_ABI bad_array_length + : public bad_alloc +{ +public: + bad_array_length() _NOEXCEPT; + virtual ~bad_array_length() _NOEXCEPT; + virtual const char* what() const _NOEXCEPT; +}; + +#define _LIBCPP_BAD_ARRAY_LENGTH_DEFINED + +#endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) + _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec struct _LIBCPP_TYPE_VIS nothrow_t {}; @@ -115,11 +142,9 @@ _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow _LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; -#undef _LIBCPP_NEW_DELETE_VIS - -_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) _NOEXCEPT {} -_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) _NOEXCEPT {} +inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {} +inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {} #endif // _LIBCPP_NEW diff --git a/external/bsd/libc++/dist/libcxx/include/numeric b/external/bsd/libc++/dist/libcxx/include/numeric index c201a5f57cb..e520c8e0d75 100644 --- a/external/bsd/libc++/dist/libcxx/include/numeric +++ b/external/bsd/libc++/dist/libcxx/include/numeric @@ -157,7 +157,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __t2 - __t1; - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; @@ -177,7 +177,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __binary_op(__t2, __t1); - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; diff --git a/external/bsd/libc++/dist/libcxx/include/optional b/external/bsd/libc++/dist/libcxx/include/optional new file mode 100644 index 00000000000..a8e6a99115d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/include/optional @@ -0,0 +1,697 @@ +// -*- C++ -*- +//===-------------------------- optional ----------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_OPTIONAL +#define _LIBCPP_OPTIONAL + +/* + optional synopsis + +// C++1y + +#include <initializer_list> + +namespace std +{ + +// optional for object types +template <class T> +class optional +{ +public: + typedef T value_type; + + // constructors + constexpr optional() noexcept; + constexpr optional(nullopt_t) noexcept; + optional(const optional&); + optional(optional&&) noexcept(is_nothrow_move_constructible<T>::value); + constexpr optional(const T&); + constexpr optional(T&&); + template <class... Args> constexpr explicit optional(in_place_t, Args&&...); + template <class U, class... Args> + constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...); + + // destructor + ~optional(); + + // assignment + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional&); + optional& operator=(optional&&) + noexcept(is_nothrow_move_assignable<T>::value && + is_nothrow_move_constructible<T>::value); + template <class U> optional& operator=(U&&); + template <class... Args> void emplace(Args&&...); + template <class U, class... Args> void emplace(initializer_list<U>, Args&&...); + + // swap + void swap(optional&) + noexcept(is_nothrow_move_constructible<T>::value && + noexcept(swap(declval<T&>(), declval<T&>()))); + + // observers + constexpr T const* operator->() const; + T* operator->(); + constexpr T const& operator*() const; + T& operator*(); + constexpr explicit operator bool() const noexcept; + constexpr T const& value() const; + T& value(); + template <class U> constexpr T value_or(U&&) const&; + template <class U> T value_or(U&&) &&; +}; + +// In-place construction +struct in_place_t{}; +constexpr in_place_t in_place{}; + +// Disengaged state indicator +struct nullopt_t{see below}; +constexpr nullopt_t nullopt(unspecified); + +// class bad_optional_access +class bad_optional_access + : public logic_error +{ +public: + explicit bad_optional_access(const string& what_arg); + explicit bad_optional_access(const char* what_arg); +}; + +// Relational operators +template <class T> constexpr bool operator==(const optional<T>&, const optional<T>&); +template <class T> constexpr bool operator< (const optional<T>&, const optional<T>&); + +// Comparison with nullopt +template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept; +template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept; +template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept; +template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept; + +// Comparison with T +template <class T> constexpr bool operator==(const optional<T>&, const T&); +template <class T> constexpr bool operator==(const T&, const optional<T>&); +template <class T> constexpr bool operator<(const optional<T>&, const T&); +template <class T> constexpr bool operator<(const T&, const optional<T>&); + +// Specialized algorithms +template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below); +template <class T> constexpr optional<typename decay<T>::type> make_optional(T&&); + +// hash support +template <class T> struct hash; +template <class T> struct hash<optional<T>>; + +} // std + +*/ + +#include <__config> +#include <functional> +#include <stdexcept> + +namespace std // purposefully not using versioning namespace +{ + +class _LIBCPP_EXCEPTION_ABI bad_optional_access + : public logic_error +{ +public: +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg) + : logic_error(__arg) {} + _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg) + : logic_error(__arg) {} + _LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default; + _LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default; +#else +private: + bad_optional_access(const bad_optional_access&); + bad_optional_access& operator=(const bad_optional_access&); +public: +#endif // _LIBCPP_STD_VER > 11 + // Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y + virtual ~bad_optional_access() _NOEXCEPT; +}; + +} // std + +#if _LIBCPP_STD_VER > 11 + +#include <initializer_list> +#include <type_traits> +#include <new> +#include <__functional_base> + +#include <__undef_min_max> + +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct in_place_t {}; +constexpr in_place_t in_place{}; + +struct nullopt_t +{ + explicit constexpr nullopt_t(int) noexcept {} +}; + +constexpr nullopt_t nullopt{0}; + +template <class _Tp, bool = is_trivially_destructible<_Tp>::value> +class __optional_storage +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + ~__optional_storage() + { + if (__engaged_) + __val_.~value_type(); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class __optional_storage<_Tp, true> +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class optional + : private __optional_storage<_Tp> +{ + typedef __optional_storage<_Tp> __base; +public: + typedef _Tp value_type; + + static_assert(!is_reference<value_type>::value, + "Instantiation of optional with a reference type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value, + "Instantiation of optional with a in_place_t type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value, + "Instantiation of optional with a nullopt_t type is ill-formed."); + static_assert(is_object<value_type>::value, + "Instantiation of optional with a non-object type is undefined behavior."); + static_assert(is_nothrow_destructible<value_type>::value, + "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior."); + + _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} + _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default; + _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default; + _LIBCPP_INLINE_VISIBILITY ~optional() = default; + _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v) + : __base(__v) {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v) + : __base(_VSTD::move(__v)) {} + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, _Args&&... __args) + : __base(in_place, _VSTD::forward<_Args>(__args)...) {} + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + optional& operator=(nullopt_t) noexcept + { + if (this->__engaged_) + { + this->__val_.~value_type(); + this->__engaged_ = false; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(const optional& __opt) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = __opt.__val_; + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(optional&& __opt) + noexcept(is_nothrow_move_assignable<value_type>::value && + is_nothrow_move_constructible<value_type>::value) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = _VSTD::move(__opt.__val_); + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + template <class _Up, + class = typename enable_if + < + is_same<typename remove_reference<_Up>::type, value_type>::value && + is_constructible<value_type, _Up>::value && + is_assignable<value_type&, _Up>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(_Up&& __v) + { + if (this->__engaged_) + this->__val_ = _VSTD::forward<_Up>(__v); + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); + this->__engaged_ = true; + } + return *this; + } + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(_Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + _LIBCPP_INLINE_VISIBILITY + void + swap(optional& __opt) + noexcept(is_nothrow_move_constructible<value_type>::value && + __is_nothrow_swappable<value_type>::value) + { + using _VSTD::swap; + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + swap(this->__val_, __opt.__val_); + } + else + { + if (this->__engaged_) + { + ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); + this->__val_.~value_type(); + } + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + __opt.__val_.~value_type(); + } + swap(this->__engaged_, __opt.__engaged_); + } + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + operator->() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return __operator_arrow(__has_operator_addressof<value_type>{}); + } + + _LIBCPP_INLINE_VISIBILITY + value_type* + operator->() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + const value_type& + operator*() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& + operator*() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + constexpr explicit operator bool() const noexcept {return this->__engaged_;} + + _LIBCPP_INLINE_VISIBILITY + constexpr value_type const& value() const + { + if (!this->__engaged_) + throw bad_optional_access("optional<T>::value: not engaged"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& value() + { + if (!this->__engaged_) + throw bad_optional_access("optional<T>::value: not engaged"); + return this->__val_; + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + constexpr value_type value_or(_Up&& __v) const& + { + static_assert(is_copy_constructible<value_type>::value, + "optional<T>::value_or: T must be copy constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? this->__val_ : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + value_type value_or(_Up&& __v) && + { + static_assert(is_move_constructible<value_type>::value, + "optional<T>::value_or: T must be move constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? _VSTD::move(this->__val_) : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + +private: + _LIBCPP_INLINE_VISIBILITY + value_type const* + __operator_arrow(true_type) const + { + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + __operator_arrow(false_type) const + { + return &this->__val_; + } +}; + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (static_cast<bool>(__x) != static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return *__x == *__y; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (!static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return less<_Tp>{}(*__x, *__y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>&, nullopt_t) noexcept +{ + return false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) +{ + __x.swap(__y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +optional<typename decay<_Tp>::type> +make_optional(_Tp&& __v) +{ + return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v)); +} + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY hash<optional<_Tp> > +{ + typedef optional<_Tp> argument_type; + typedef size_t result_type; + + _LIBCPP_INLINE_VISIBILITY + result_type operator()(const argument_type& __opt) const _NOEXCEPT + { + return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0; + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_ARRAY diff --git a/external/bsd/libc++/dist/libcxx/include/ostream b/external/bsd/libc++/dist/libcxx/include/ostream index 2c618d41b9d..041314acc75 100644 --- a/external/bsd/libc++/dist/libcxx/include/ostream +++ b/external/bsd/libc++/dist/libcxx/include/ostream @@ -1159,7 +1159,8 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { - if (!this->fail()) + sentry __s(*this); + if (__s) { if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) this->setstate(ios_base::failbit); @@ -1172,8 +1173,12 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { - if (!this->fail()) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); + sentry __s(*this); + if (__s) + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) + this->setstate(ios_base::failbit); + } return *this; } diff --git a/external/bsd/libc++/dist/libcxx/include/random b/external/bsd/libc++/dist/libcxx/include/random index c5f7584994f..c0db1abacc0 100644 --- a/external/bsd/libc++/dist/libcxx/include/random +++ b/external/bsd/libc++/dist/libcxx/include/random @@ -3475,7 +3475,9 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b; class _LIBCPP_TYPE_VIS random_device { +#if !defined(_WIN32) int __f_; +#endif // defined(_WIN32) public: // types typedef unsigned result_type; @@ -3521,7 +3523,7 @@ private: public: // constructors _LIBCPP_INLINE_VISIBILITY - seed_seq() {} + seed_seq() _NOEXCEPT {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template<class _Tp> _LIBCPP_INLINE_VISIBILITY @@ -3539,7 +3541,7 @@ public: // property functions _LIBCPP_INLINE_VISIBILITY - size_t size() const {return __v_.size();} + size_t size() const _NOEXCEPT {return __v_.size();} template<class _OutputIterator> _LIBCPP_INLINE_VISIBILITY void param(_OutputIterator __dest) const diff --git a/external/bsd/libc++/dist/libcxx/include/regex b/external/bsd/libc++/dist/libcxx/include/regex index 776bc653ce4..ffe39cf1cff 100644 --- a/external/bsd/libc++/dist/libcxx/include/regex +++ b/external/bsd/libc++/dist/libcxx/include/regex @@ -970,7 +970,7 @@ public: bool isctype(char_type __c, char_class_type __m) const; _LIBCPP_INLINE_VISIBILITY int value(char_type __ch, int __radix) const - {return __value(__ch, __radix);} + {return __regex_traits_value(__ch, __radix);} locale_type imbue(locale_type __l); _LIBCPP_INLINE_VISIBILITY locale_type getloc()const {return __loc_;} @@ -1001,11 +1001,11 @@ private: __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; - static int __value(unsigned char __ch, int __radix); + static int __regex_traits_value(unsigned char __ch, int __radix); _LIBCPP_INLINE_VISIBILITY - int __value(char __ch, int __radix) const - {return __value(static_cast<unsigned char>(__ch), __radix);} - int __value(wchar_t __ch, int __radix) const; + int __regex_traits_value(char __ch, int __radix) const + {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);} + int __regex_traits_value(wchar_t __ch, int __radix) const; }; template <class _CharT> @@ -1207,7 +1207,7 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const template <class _CharT> int -regex_traits<_CharT>::__value(unsigned char __ch, int __radix) +regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) { if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' return __ch - '0'; @@ -1228,9 +1228,9 @@ regex_traits<_CharT>::__value(unsigned char __ch, int __radix) template <class _CharT> inline _LIBCPP_INLINE_VISIBILITY int -regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const +regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { - return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); + return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); } template <class _CharT> class __node; @@ -3785,7 +3785,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, } __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -3793,7 +3793,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, __ml->__add_digraph(__start_range[0], __start_range[1]); } } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); diff --git a/external/bsd/libc++/dist/libcxx/include/set b/external/bsd/libc++/dist/libcxx/include/set index 70b8d28f7e5..a537c5fe345 100644 --- a/external/bsd/libc++/dist/libcxx/include/set +++ b/external/bsd/libc++/dist/libcxx/include/set @@ -66,6 +66,11 @@ public: set(initializer_list<value_type> il, const value_compare& comp = value_compare()); set(initializer_list<value_type> il, const value_compare& comp, const allocator_type& a); + template <class InputIterator> + set(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + set(initializer_list<value_type> il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~set(); set& operator=(const set& s); @@ -242,6 +247,11 @@ public: multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); multiset(initializer_list<value_type> il, const value_compare& comp, const allocator_type& a); + template <class InputIterator> + multiset(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + multiset(initializer_list<value_type> il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~multiset(); multiset& operator=(const multiset& s); @@ -442,6 +452,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : set(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set(const set& __s) : __tree_(__s.__tree_) @@ -494,6 +511,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + set(initializer_list<value_type> __il, const allocator_type& __a) + : set(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set& operator=(initializer_list<value_type> __il) { @@ -817,6 +840,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multiset(__f, __l, key_compare(), __a) {} +#endif + template <class _InputIterator> _LIBCPP_INLINE_VISIBILITY multiset(_InputIterator __f, _InputIterator __l, @@ -876,6 +906,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multiset(initializer_list<value_type> __il, const allocator_type& __a) + : multiset(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multiset& operator=(initializer_list<value_type> __il) { diff --git a/external/bsd/libc++/dist/libcxx/include/shared_mutex b/external/bsd/libc++/dist/libcxx/include/shared_mutex new file mode 100644 index 00000000000..5b1f53aafe8 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/include/shared_mutex @@ -0,0 +1,419 @@ +// -*- C++ -*- +//===------------------------ shared_mutex --------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SHARED_MUTEX +#define _LIBCPP_SHARED_MUTEX + +/* + shared_mutex synopsis + +// C++1y + +namespace std +{ + +class shared_mutex +{ +public: + shared_mutex(); + ~shared_mutex(); + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + template <class Rep, class Period> + bool + try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool + try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock_shared(); +}; + +template <class Mutex> +class shared_lock +{ +public: + typedef Mutex mutex_type; + + // Shared locking + shared_lock() noexcept; + explicit shared_lock(mutex_type& m); // blocking + shared_lock(mutex_type& m, defer_lock_t) noexcept; + shared_lock(mutex_type& m, try_to_lock_t); + shared_lock(mutex_type& m, adopt_lock_t); + template <class Clock, class Duration> + shared_lock(mutex_type& m, + const chrono::time_point<Clock, Duration>& abs_time); + template <class Rep, class Period> + shared_lock(mutex_type& m, + const chrono::duration<Rep, Period>& rel_time); + ~shared_lock(); + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + shared_lock(shared_lock&& u) noexcept; + shared_lock& operator=(shared_lock&& u) noexcept; + + void lock(); // blocking + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Setters + void swap(shared_lock& u) noexcept; + mutex_type* release() noexcept; + + // Getters + bool owns_lock() const noexcept; + explicit operator bool () const noexcept; + mutex_type* mutex() const noexcept; +}; + +template <class Mutex> + void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept; + +} // std + +*/ + +#include <__config> + +#if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX) + +#include <__mutex_base> + +#include <__undef_min_max> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_TYPE_VIS shared_mutex +{ + mutex __mut_; + condition_variable __gate1_; + condition_variable __gate2_; + unsigned __state_; + + static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1); + static const unsigned __n_readers_ = ~__write_entered_; +public: + shared_mutex(); + _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default; + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); + bool try_lock(); + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_until(chrono::steady_clock::now() + __rel_time); + } + template <class _Clock, class _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); + bool try_lock_shared(); + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_shared_until(chrono::steady_clock::now() + __rel_time); + } + template <class _Clock, class _Duration> + bool + try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock_shared(); +}; + +template <class _Clock, class _Duration> +bool +shared_mutex::try_lock_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock<mutex> __lk(__mut_); + if (__state_ & __write_entered_) + { + while (true) + { + cv_status __status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0) + break; + if (__status == cv_status::timeout) + return false; + } + } + __state_ |= __write_entered_; + if (__state_ & __n_readers_) + { + while (true) + { + cv_status __status = __gate2_.wait_until(__lk, __abs_time); + if ((__state_ & __n_readers_) == 0) + break; + if (__status == cv_status::timeout) + { + __state_ &= ~__write_entered_; + return false; + } + } + } + return true; +} + +template <class _Clock, class _Duration> +bool +shared_mutex::try_lock_shared_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock<mutex> __lk(__mut_); + if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + { + while (true) + { + cv_status status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0 && + (__state_ & __n_readers_) < __n_readers_) + break; + if (status == cv_status::timeout) + return false; + } + } + unsigned __num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= __num_readers; + return true; +} + +template <class _Mutex> +class shared_lock +{ +public: + typedef _Mutex mutex_type; + +private: + mutex_type* __m_; + bool __owns_; + +public: + _LIBCPP_INLINE_VISIBILITY + shared_lock() noexcept + : __m_(nullptr), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit shared_lock(mutex_type& __m) + : __m_(&__m), + __owns_(true) + {__m_->lock_shared();} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, defer_lock_t) noexcept + : __m_(&__m), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, try_to_lock_t) + : __m_(&__m), + __owns_(__m.try_lock_shared()) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, adopt_lock_t) + : __m_(&__m), + __owns_(true) + {} + + template <class _Clock, class _Duration> + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __abs_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_until(__abs_time)) + {} + + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rel_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_for(__rel_time)) + {} + + _LIBCPP_INLINE_VISIBILITY + ~shared_lock() + { + if (__owns_) + __m_->unlock_shared(); + } + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + _LIBCPP_INLINE_VISIBILITY + shared_lock(shared_lock&& __u) noexcept + : __m_(__u.__m_), + __owns_(__u.__owns_) + { + __u.__m_ = nullptr; + __u.__owns_ = false; + } + + _LIBCPP_INLINE_VISIBILITY + shared_lock& operator=(shared_lock&& __u) noexcept + { + if (__owns_) + __m_->unlock_shared(); + __m_ = nullptr; + __owns_ = false; + __m_ = __u.__m_; + __owns_ = __u.__owns_; + __u.__m_ = nullptr; + __u.__owns_ = false; + return *this; + } + + void lock(); + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Setters + _LIBCPP_INLINE_VISIBILITY + void swap(shared_lock& __u) noexcept + { + _VSTD::swap(__m_, __u.__m_); + _VSTD::swap(__owns_, __u.__owns_); + } + + _LIBCPP_INLINE_VISIBILITY + mutex_type* release() noexcept + { + mutex_type* __m = __m_; + __m_ = nullptr; + __owns_ = false; + return __m; + } + + // Getters + _LIBCPP_INLINE_VISIBILITY + bool owns_lock() const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + explicit operator bool () const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + mutex_type* mutex() const noexcept {return __m_;} +}; + +template <class _Mutex> +void +shared_lock<_Mutex>::lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::lock: already locked"); + __m_->lock_shared(); + __owns_ = true; +} + +template <class _Mutex> +bool +shared_lock<_Mutex>::try_lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked"); + __owns_ = __m_->try_lock_shared(); + return __owns_; +} + +template <class _Mutex> +template <class _Rep, class _Period> +bool +shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked"); + __owns_ = __m_->try_lock_shared_for(__d); + return __owns_; +} + +template <class _Mutex> +template <class _Clock, class _Duration> +bool +shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked"); + __owns_ = __m_->try_lock_shared_until(__t); + return __owns_; +} + +template <class _Mutex> +void +shared_lock<_Mutex>::unlock() +{ + if (!__owns_) + __throw_system_error(EPERM, "shared_lock::unlock: not locked"); + __m_->unlock_shared(); + __owns_ = false; +} + +template <class _Mutex> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept + {__x.swap(__y);} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_SHARED_MUTEX diff --git a/external/bsd/libc++/dist/libcxx/include/string b/external/bsd/libc++/dist/libcxx/include/string index 7439b5615bb..e8bd69fcabd 100644 --- a/external/bsd/libc++/dist/libcxx/include/string +++ b/external/bsd/libc++/dist/libcxx/include/string @@ -447,7 +447,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS #include <cstdint> #endif -#if defined(_LIBCPP_NO_EXCEPTIONS) || defined(_LIBCPP_DEBUG) +#if defined(_LIBCPP_NO_EXCEPTIONS) #include <cassert> #endif @@ -605,6 +605,7 @@ inline _LIBCPP_INLINE_VISIBILITY _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -656,7 +657,10 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char> {return (char_type*)memmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memcpy(__s1, __s2, __n);} + { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + return (char_type*)memcpy(__s1, __s2, __n); + } _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)memset(__s, to_int_type(__a), __n);} @@ -713,7 +717,10 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t> {return (char_type*)wmemmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemcpy(__s1, __s2, __n);} + { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + return (char_type*)wmemcpy(__s1, __s2, __n); + } _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)wmemset(__s, __a, __n);} @@ -841,6 +848,7 @@ inline _LIBCPP_INLINE_VISIBILITY char16_t* char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -961,6 +969,7 @@ inline _LIBCPP_INLINE_VISIBILITY char32_t* char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -1072,13 +1081,13 @@ public: typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter<basic_string, pointer> iterator; - typedef __debug_iter<basic_string, const_pointer> const_iterator; - friend class __debug_iter<basic_string, pointer>; - friend class __debug_iter<basic_string, const_pointer>; -#elif defined(_LIBCPP_RAW_ITERATORS) + static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD"); + static_assert((is_same<_CharT, value_type>::value), + "traits_type::char_type must be the same type as CharT"); + static_assert((is_same<typename allocator_type::value_type, value_type>::value), + "Allocator::value_type must be same type as value_type"); +#if defined(_LIBCPP_RAW_ITERATORS) typedef pointer iterator; typedef const_pointer const_iterator; #else // defined(_LIBCPP_RAW_ITERATORS) @@ -1152,9 +1161,9 @@ private: #endif // _LIBCPP_ALTERNATE_STRING_LAYOUT - union __lx{__long __lx; __short __lxx;}; + union __ulx{__long __lx; __short __lxx;}; - enum {__n_words = sizeof(__lx) / sizeof(size_type)}; + enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; struct __raw { @@ -1173,15 +1182,6 @@ private: __compressed_pair<__rep, allocator_type> __r_; -#ifdef _LIBCPP_DEBUG - - pair<iterator*, const_iterator*> __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} - -#endif // _LIBCPP_DEBUG - public: static const size_type npos = -1; @@ -1239,7 +1239,20 @@ public: basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#ifndef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + iterator begin() _NOEXCEPT + {return iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + const_iterator begin() const _NOEXCEPT + {return const_iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + iterator end() _NOEXCEPT + {return iterator(this, __get_pointer() + size());} + _LIBCPP_INLINE_VISIBILITY + const_iterator end() const _NOEXCEPT + {return const_iterator(this, __get_pointer() + size());} +#else _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__get_pointer());} @@ -1252,12 +1265,7 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__get_pointer() + size());} -#else // _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(this, __get_pointer());} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return const_iterator(this, data());} - _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(this, __get_pointer() + size());} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const {return const_iterator(this, data() + size());} -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} @@ -1520,6 +1528,15 @@ public: bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);} +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const; + bool __decrementable(const const_iterator* __i) const; + bool __addable(const const_iterator* __i, ptrdiff_t __n) const; + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT @@ -1732,75 +1749,64 @@ private: }; template <class _CharT, class _Traits, class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__invalidate_all(this); +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template <class _CharT, class _Traits, class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type -#ifdef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 __pos #endif ) { -#ifdef _LIBCPP_DEBUG - const_iterator __beg = begin(); - if (__iterator_list_.first) - { - for (iterator* __p = __iterator_list_.first; __p;) - { - if (*__p - __beg > static_cast<difference_type>(__pos)) - { - iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); - } - else - __p = __p->__next; - } - } - if (__iterator_list_.second) +#if _LIBCPP_DEBUG_LEVEL >= 2 + __c_node* __c = __get_db()->__find_c_and_lock(this); + if (__c) { - for (const_iterator* __p = __iterator_list_.second; __p;) + const_pointer __new_last = __get_pointer() + __pos; + for (__i_node** __p = __c->end_; __p != __c->beg_; ) { - if (*__p - __beg > static_cast<difference_type>(__pos)) + --__p; + const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); + if (__i->base() > __new_last) { - const_iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } - else - __p = __p->__next; } + __get_db()->unlock(); } -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) : __r_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } @@ -1853,45 +1859,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1902,6 +1912,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1912,24 +1925,29 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__a) { @@ -1938,8 +1956,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } @@ -1970,18 +1990,24 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c, const allocator_type& __a) : __r_(__a) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1993,6 +2019,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st if (__pos > __str_sz) this->__throw_out_of_range(); __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -2056,37 +2085,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For template <class _CharT, class _Traits, class _Allocator> template<class _InputIterator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> template<class _InputIterator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__a) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il, const allocator_type& __a) : __r_(__a) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2094,7 +2135,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_t template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>::~basic_string() { - __invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__erase_c(this); +#endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } @@ -2138,7 +2181,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t size_type __n_copy, size_type __n_del, size_type __n_add) { size_type __ms = max_size(); - if (__delta_cap > __ms - __old_cap - 1) + if (__delta_cap > __ms - __old_cap) this->__throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? @@ -2166,9 +2209,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr"); size_type __cap = capacity(); if (__cap >= __n) { @@ -2241,7 +2282,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) { @@ -2252,7 +2293,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) @@ -2265,7 +2306,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -2321,7 +2362,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str) { @@ -2342,9 +2383,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr"); return assign(__s, traits_type::length(__s)); } @@ -2354,9 +2393,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) @@ -2472,7 +2509,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) { @@ -2493,9 +2530,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr"); return append(__s, traits_type::length(__s)); } @@ -2505,9 +2540,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2576,13 +2609,22 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __old_sz = size(); difference_type __ip = __pos - begin(); for (; __first != __last; ++__first) push_back(*__first); pointer __p = __get_pointer(); _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(this, __p + __ip); +#else return iterator(__p + __ip); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -2594,6 +2636,11 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __ip = static_cast<size_type>(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); @@ -2623,7 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) { @@ -2645,9 +2692,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr"); return insert(__pos, __s, traits_type::length(__s)); } @@ -2678,10 +2723,15 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, n, value) called with an iterator not" + " referring to this string"); +#endif difference_type __p = __pos - begin(); insert(static_cast<size_type>(__p), __n, __c); return begin() + __p; @@ -2693,9 +2743,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2805,7 +2853,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) { @@ -2827,14 +2875,12 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) { @@ -2843,7 +2889,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) { @@ -2851,7 +2897,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) { @@ -2859,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) { @@ -2891,10 +2937,17 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::erase(iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__pos != end(), + "string::erase(iterator) called with a non-dereferenceable iterator"); iterator __b = begin(); size_type __r = static_cast<size_type>(__pos - __b); erase(__r, 1); @@ -2902,10 +2955,16 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, + "string::erase(iterator, iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); iterator __b = begin(); size_type __r = static_cast<size_type>(__first - __b); erase(__r, static_cast<size_type>(__last - __first)); @@ -2913,13 +2972,11 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::pop_back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); size_type __sz; if (__is_long()) { @@ -2937,7 +2994,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back() } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { @@ -2955,7 +3012,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) { @@ -2984,15 +3041,15 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT { size_type __m = __alloc_traits::max_size(__alloc()); #if _LIBCPP_BIG_ENDIAN - return (__m <= ~__long_mask ? __m : __m/2) - 1; + return (__m <= ~__long_mask ? __m : __m/2) - __alignment; #else - return __m - 1; + return __m - __alignment; #endif } @@ -3060,24 +3117,20 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const { -#ifdef __LIBCPP_DEBUG - assert(__pos <= size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(data() + __pos); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) { -#ifdef __LIBCPP_DEBUG - assert(__pos < size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(__get_pointer() + __pos); } @@ -3100,46 +3153,38 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::front() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *__get_pointer(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::front() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *data(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(__get_pointer() + size() - 1); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::back() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(data() + size() - 1); } @@ -3156,7 +3201,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const { @@ -3164,18 +3209,21 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + if (!__is_long()) + __get_db()->__invalidate_all(this); + if (!__str.__is_long()) + __get_db()->__invalidate_all(&__str); + __get_db()->swap(this, &__str); +#endif _VSTD::swap(__r_.first(), __str.__r_.first()); __swap_alloc(__alloc(), __str.__alloc()); -#ifdef _LIBCPP_DEBUG - __invalidate_all_iterators(); - __str.__invalidate_all_iterators(); -#endif // _LIBCPP_DEBUG } // find @@ -3195,9 +3243,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr"); size_type __sz = size(); if (__pos > __sz || __sz - __pos < __n) return npos; @@ -3212,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3221,14 +3267,12 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr"); return find(__s, __pos, traits_type::length(__s)); } @@ -3255,9 +3299,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr"); size_type __sz = size(); __pos = _VSTD::min(__pos, __sz); if (__n < __sz - __pos) @@ -3273,7 +3315,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3282,14 +3324,12 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr"); return rfind(__s, __pos, traits_type::length(__s)); } @@ -3323,9 +3363,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr"); size_type __sz = size(); if (__pos >= __sz || __n == 0) return npos; @@ -3338,7 +3376,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3347,19 +3385,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr"); return find_first_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3375,9 +3411,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr"); if (__n != 0) { size_type __sz = size(); @@ -3397,7 +3431,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3406,19 +3440,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr"); return find_last_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3434,9 +3466,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) { @@ -3450,7 +3480,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3459,19 +3489,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr"); return find_first_not_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3496,9 +3524,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) ++__pos; @@ -3512,7 +3538,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3521,19 +3547,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr"); return find_last_not_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3553,7 +3577,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, // compare template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { @@ -3571,7 +3595,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, @@ -3599,9 +3623,7 @@ template <class _CharT, class _Traits, class _Allocator> int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(0, npos, __s, traits_type::length(__s)); } @@ -3611,9 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); } @@ -3624,9 +3644,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, const value_type* __s, size_type __n2) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) this->__throw_out_of_range(); @@ -3645,7 +3663,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, // __invariants template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const { @@ -3663,7 +3681,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const // operator== template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3675,7 +3693,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT @@ -3694,7 +3712,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3703,7 +3721,7 @@ operator==(const _CharT* __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3714,7 +3732,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, // operator!= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3723,7 +3741,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3732,7 +3750,7 @@ operator!=(const _CharT* __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3743,7 +3761,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, // operator< template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3752,7 +3770,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3761,7 +3779,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3772,7 +3790,7 @@ operator< (const _CharT* __lhs, // operator> template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3781,7 +3799,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3790,7 +3808,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3801,7 +3819,7 @@ operator> (const _CharT* __lhs, // operator<= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3810,7 +3828,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3819,7 +3837,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3830,7 +3848,7 @@ operator<=(const _CharT* __lhs, // operator>= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3839,7 +3857,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3848,7 +3866,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3920,7 +3938,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { @@ -3928,7 +3946,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string< } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3936,7 +3954,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3944,7 +3962,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3952,7 +3970,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3961,7 +3979,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { @@ -3969,7 +3987,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { @@ -3982,7 +4000,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) // swap template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) @@ -4102,12 +4120,45 @@ getline(basic_istream<_CharT, _Traits>&& __is, #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_DEBUG_LEVEL >= 2 + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const +{ + return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const +{ + return this->data() < _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p <= this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p < this->data() + this->size(); +} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + #if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] -// inline // Deviation from N3690. -// We believe the inline to be a defect and have submitted an LWG issue. -// An LWG issue number has not yet been assigned. -namespace literals +inline namespace literals { inline namespace string_literals { @@ -4140,10 +4191,7 @@ namespace literals _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<wchar_t>) - -extern template - string - operator+<char, char_traits<char>, allocator<char> >(char const*, string const&); +_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) _LIBCPP_END_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/include/system_error b/external/bsd/libc++/dist/libcxx/include/system_error index ac3fb4474d7..66bf6d6c424 100644 --- a/external/bsd/libc++/dist/libcxx/include/system_error +++ b/external/bsd/libc++/dist/libcxx/include/system_error @@ -22,6 +22,7 @@ class error_category public: virtual ~error_category() noexcept; + constexpr error_category(); error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; @@ -366,7 +367,12 @@ class _LIBCPP_TYPE_VIS error_category public: virtual ~error_category() _NOEXCEPT; +#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR error_category() _NOEXCEPT; +#else + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT; +#endif private: error_category(const error_category&);// = delete; error_category& operator=(const error_category&);// = delete; diff --git a/external/bsd/libc++/dist/libcxx/include/tuple b/external/bsd/libc++/dist/libcxx/include/tuple index 1829932e14a..a1a7bcf0b5e 100644 --- a/external/bsd/libc++/dist/libcxx/include/tuple +++ b/external/bsd/libc++/dist/libcxx/include/tuple @@ -73,7 +73,7 @@ public: const unspecified ignore; template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 -template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; +template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 template <class... T> tuple<T&...> tie(T&...) noexcept; template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14 @@ -133,68 +133,6 @@ template <class... Types> _LIBCPP_BEGIN_NAMESPACE_STD -// allocator_arg_t - -struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { }; - -#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) -extern const allocator_arg_t allocator_arg; -#else -constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template <class _Tp> -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> -struct __uses_allocator - : public integral_constant<bool, - is_convertible<_Alloc, typename _Tp::allocator_type>::value> -{ -}; - -template <class _Tp, class _Alloc> -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template <class _Tp, class _Alloc> -struct _LIBCPP_TYPE_VIS_ONLY uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#ifndef _LIBCPP_HAS_NO_VARIADICS - -// uses-allocator construction - -template <class _Tp, class _Alloc, class ..._Args> -struct __uses_alloc_ctor_imp -{ - static const bool __ua = uses_allocator<_Tp, _Alloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template <class _Tp, class _Alloc, class ..._Args> -struct __uses_alloc_ctor - : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> - {}; - -#endif // _LIBCPP_HAS_NO_VARIADICS - #ifndef _LIBCPP_HAS_NO_VARIADICS // tuple_size @@ -332,7 +270,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value) - : value(_VSTD::move(__t.get())) + : value(_VSTD::forward<_Hp>(__t.get())) {} template <class _Tp> @@ -519,13 +457,24 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> return *this; } - _LIBCPP_INLINE_VISIBILITY - __tuple_impl& - operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) - { - __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); - return *this; - } + __tuple_impl(const __tuple_impl&) = default; + __tuple_impl(__tuple_impl&&) = default; + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...); + return *this; + } _LIBCPP_INLINE_VISIBILITY void swap(__tuple_impl& __t) @@ -810,7 +759,7 @@ struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> { static constexpr size_t value = std::conditional< std::is_same<_T1, _Head>::value, - __find_exactly_one_t_checker<_T1, _Idx, Â Â _Args...>, + __find_exactly_one_t_checker<_T1, _Idx, _Args...>, __find_exactly_one_t_helper <_T1, _Idx+1, _Args...> >::type::value; }; @@ -895,14 +844,6 @@ make_tuple(_Tp&&... __t) template <class... _Tp> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&&...> -__forward_as_tuple(_Tp&&... __t) _NOEXCEPT -{ - return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); -} - -template <class... _Tp> -inline _LIBCPP_INLINE_VISIBILITY -tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT { return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); @@ -1103,7 +1044,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0) { - return __forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., + return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); } @@ -1118,7 +1059,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>, typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type, typename __make_tuple_indices<tuple_size<_T1>::value>::type>() - (__forward_as_tuple( + (forward_as_tuple( _VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))... ), diff --git a/external/bsd/libc++/dist/libcxx/include/type_traits b/external/bsd/libc++/dist/libcxx/include/type_traits index 73ece1ea2fa..b6430fbbc9a 100644 --- a/external/bsd/libc++/dist/libcxx/include/type_traits +++ b/external/bsd/libc++/dist/libcxx/include/type_traits @@ -28,6 +28,7 @@ namespace std // Primary classification traits: template <class T> struct is_void; + template <class T> struct is_null_pointer; // C++14 template <class T> struct is_integral; template <class T> struct is_floating_point; template <class T> struct is_array; @@ -298,6 +299,11 @@ template <> struct ____is_nullptr_t<nullptr_t> : public true_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 11 +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer + : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {}; +#endif + // is_integral template <class _Tp> struct __is_integral : public false_type {}; @@ -422,7 +428,7 @@ template <class _Tp, bool = is_class<_Tp>::value || is_union<_Tp>::value || is_void<_Tp>::value || is_reference<_Tp>::value || - is_same<_Tp, nullptr_t>::value > + __is_nullptr_t<_Tp>::value > struct __is_function : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1> {}; @@ -713,6 +719,31 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif +// decay + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename conditional + < + is_array<_Up>::value, + typename remove_extent<_Up>::type*, + typename conditional + < + is_function<_Up>::value, + typename add_pointer<_Up>::type, + typename remove_cv<_Up>::type + >::type + >::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template <class _Tp> using decay_t = typename decay<_Tp>::type; +#endif + // is_abstract namespace __is_abstract_imp @@ -1350,7 +1381,7 @@ template <class ..._Tp> struct common_type; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { - typedef _Tp type; + typedef typename decay<_Tp>::type type; }; template <class _Tp, class _Up> @@ -1361,7 +1392,7 @@ private: static _Up&& __u(); static bool __f(); public: - typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type; + typedef typename decay<decltype(__f() ? __t() : __u())>::type type; }; template <class _Tp, class _Up, class ..._Vp> @@ -1378,8 +1409,10 @@ template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type // is_assignable +template<typename, typename T> struct __select_2nd { typedef T type; }; + template <class _Tp, class _Arg> -decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type())) +typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(_Tp&&, _Arg&&); #else @@ -1446,7 +1479,8 @@ __is_destructible_test(_Tp&); false_type __is_destructible_test(__any); -template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value> +template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value + || is_function<_Tp>::value> struct __destructible_imp : public common_type < @@ -1537,29 +1571,6 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> -struct _LIBCPP_TYPE_VIS_ONLY decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; -public: - typedef typename conditional - < - is_array<_Up>::value, - typename remove_extent<_Up>::type*, - typename conditional - < - is_function<_Up>::value, - typename add_pointer<_Up>::type, - typename remove_cv<_Up>::type - >::type - >::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <class _Tp> using decay_t = typename decay<_Tp>::type; -#endif - #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp> @@ -1968,8 +1979,6 @@ class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> // main is_constructible test -template<typename, typename T> struct __select_2nd { typedef T type; }; - template <class _Tp, class ..._Args> typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type __is_constructible_test(_Tp&&, _Args&& ...); @@ -3257,6 +3266,27 @@ struct underlying_type #endif // _LIBCXX_UNDERLYING_TYPE +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + +template <class _Tp> +struct __has_operator_addressof_imp +{ + template <class> + static auto __test(__any) -> false_type; + template <class _Up> + static auto __test(_Up* __u) + -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; + + static const bool value = decltype(__test<_Tp>(nullptr))::value; +}; + +template <class _Tp> +struct __has_operator_addressof + : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> +{}; + +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS diff --git a/external/bsd/libc++/dist/libcxx/include/unordered_map b/external/bsd/libc++/dist/libcxx/include/unordered_map index 7b5bdb6499e..78fee4811fa 100644 --- a/external/bsd/libc++/dist/libcxx/include/unordered_map +++ b/external/bsd/libc++/dist/libcxx/include/unordered_map @@ -69,6 +69,22 @@ public: unordered_map(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_map(size_type n, const allocator_type& a) + : unordered_map(n, hasher(), key_equal(), a) {} // C++14 + unordered_map(size_type n, const hasher& hf, const allocator_type& a) + : unordered_map(n, hf, key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a) + : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(il, n, hf, key_equal(), a) {} // C++14 ~unordered_map(); unordered_map& operator=(const unordered_map&); unordered_map& operator=(unordered_map&&) @@ -217,6 +233,22 @@ public: unordered_multimap(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multimap(size_type n, const allocator_type& a) + : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) + : unordered_multimap(n, hf, key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a) + : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 ~unordered_multimap(); unordered_multimap& operator=(const unordered_multimap&); unordered_multimap& operator=(unordered_multimap&&) @@ -493,6 +525,71 @@ public: } }; +#if __cplusplus >= 201103L + +template <class _Key, class _Tp> +union __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + typedef pair<key_type, mapped_type> __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template <class ..._Args> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const __hash_value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(__hash_value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(const __hash_value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(__hash_value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__hash_value_type() {__cc.~value_type();} +}; + +#else + +template <class _Key, class _Tp> +struct __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type() {} + + template <class _A0> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0) + : __cc(__a0) {} + + template <class _A0, class _A1> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { @@ -628,49 +725,7 @@ public: "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_map::value_type value_type; - typedef typename unordered_map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_map::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type<key_type, mapped_type> __value_type; typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; typedef typename allocator_traits<allocator_type>::template @@ -745,6 +800,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_map(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_map() = default; _LIBCPP_INLINE_VISIBILITY unordered_map& operator=(const unordered_map& __u) @@ -1211,7 +1290,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1258,7 +1337,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -1383,49 +1462,7 @@ public: "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_multimap::value_type value_type; - typedef typename unordered_multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type<key_type, mapped_type> __value_type; typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; typedef typename allocator_traits<allocator_type>::template @@ -1499,6 +1536,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_multimap() = default; _LIBCPP_INLINE_VISIBILITY unordered_multimap& operator=(const unordered_multimap& __u) diff --git a/external/bsd/libc++/dist/libcxx/include/unordered_set b/external/bsd/libc++/dist/libcxx/include/unordered_set index b5b734784b4..fd378fa0714 100644 --- a/external/bsd/libc++/dist/libcxx/include/unordered_set +++ b/external/bsd/libc++/dist/libcxx/include/unordered_set @@ -68,6 +68,16 @@ public: unordered_set(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_set(size_type n, const allocator_type& a); // C++14 + unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 + unordered_set(initializer_list<value_type> il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_set(); unordered_set& operator=(const unordered_set&); unordered_set& operator=(unordered_set&&) @@ -207,6 +217,16 @@ public: unordered_multiset(initializer_list<value_type>, size_type n = /see below/, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multiset(size_type n, const allocator_type& a); // C++14 + unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 + unordered_multiset(initializer_list<value_type> il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_multiset(); unordered_multiset& operator=(const unordered_multiset&); unordered_multiset& operator=(unordered_multiset&&) @@ -353,6 +373,14 @@ public: } explicit unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) {} +#endif unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); template <class _InputIterator> @@ -365,6 +393,17 @@ public: unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_set(const allocator_type& __a); unordered_set(const unordered_set& __u); unordered_set(const unordered_set& __u, const allocator_type& __a); @@ -381,6 +420,16 @@ public: unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list<value_type> __il, size_type __n, + const allocator_type& __a) + : unordered_set(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list<value_type> __il, size_type __n, + const hasher& __hf, const allocator_type& __a) + : unordered_set(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_set() = default; _LIBCPP_INLINE_VISIBILITY @@ -861,6 +910,14 @@ public: const key_equal& __eql = key_equal()); unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) {} +#endif template <class _InputIterator> unordered_multiset(_InputIterator __first, _InputIterator __last); template <class _InputIterator> @@ -871,6 +928,18 @@ public: unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n , const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_multiset(const allocator_type& __a); unordered_multiset(const unordered_multiset& __u); unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); @@ -887,6 +956,14 @@ public: unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_multiset() = default; _LIBCPP_INLINE_VISIBILITY diff --git a/external/bsd/libc++/dist/libcxx/include/utility b/external/bsd/libc++/dist/libcxx/include/utility index 1e1ce5876e6..5fc2cf205bc 100644 --- a/external/bsd/libc++/dist/libcxx/include/utility +++ b/external/bsd/libc++/dist/libcxx/include/utility @@ -594,7 +594,7 @@ struct __get_pair<1> }; template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(pair<_T1, _T2>& __p) _NOEXCEPT { @@ -602,7 +602,7 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT } template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>& __p) _NOEXCEPT { @@ -612,7 +612,7 @@ get(const pair<_T1, _T2>& __p) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { @@ -623,42 +623,42 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT #if _LIBCPP_STD_VER > 11 template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT { return __get_pair<0>::get(_VSTD::move(__p)); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT { return __get_pair<1>::get(_VSTD::move(__p)); @@ -754,7 +754,7 @@ template<class... _Tp> #if _LIBCPP_STD_VER > 11 template<class _T1, class _T2 = _T1> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _T1 exchange(_T1& __obj, _T2 && __new_value) { _T1 __old_value = _VSTD::move(__obj); diff --git a/external/bsd/libc++/dist/libcxx/include/valarray b/external/bsd/libc++/dist/libcxx/include/valarray index d4e9015b69c..5113516e9b7 100644 --- a/external/bsd/libc++/dist/libcxx/include/valarray +++ b/external/bsd/libc++/dist/libcxx/include/valarray @@ -2628,7 +2628,7 @@ public: }; template<class _ValExpr> -__val_expr<_ValExpr>::operator valarray<result_type>() const +__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const { valarray<result_type> __r; size_t __n = __expr_.size(); diff --git a/external/bsd/libc++/dist/libcxx/include/vector b/external/bsd/libc++/dist/libcxx/include/vector index 2915e127162..6ac78d5d50b 100644 --- a/external/bsd/libc++/dist/libcxx/include/vector +++ b/external/bsd/libc++/dist/libcxx/include/vector @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit vector(const allocator_type&); explicit vector(size_type n); + explicit vector(size_type n, const allocator_type&); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template <class InputIterator> vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); @@ -161,7 +162,8 @@ public: vector() noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit vector(const allocator_type&); - explicit vector(size_type n, const value_type& value = value_type(), const allocator_type& = allocator_type()); + explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 + vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template <class InputIterator> vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); vector(const vector& x); @@ -274,7 +276,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -438,7 +440,7 @@ private: }; template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -447,7 +449,7 @@ __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __begin_(nullptr), @@ -457,7 +459,7 @@ __vector_base<_Tp, _Allocator>::__vector_base() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) : __begin_(nullptr), __end_(nullptr), @@ -516,15 +518,19 @@ public: #endif } explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const_reference __x); vector(size_type __n, const_reference __x, const allocator_type& __a); template <class _InputIterator> - vector(_InputIterator __first, _InputIterator __last, + vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last); template <class _InputIterator> vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && @@ -533,11 +539,12 @@ public: value_type, typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); template <class _ForwardIterator> - vector(_ForwardIterator __first, _ForwardIterator __last, + vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last); template <class _ForwardIterator> vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && @@ -890,7 +897,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { @@ -928,7 +935,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -1022,6 +1029,22 @@ vector<_Tp, _Allocator>::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Allocator> +vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) + : __base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n); + } +} +#endif + template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) { @@ -1051,12 +1074,13 @@ vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const alloca template <class _Tp, class _Allocator> template <class _InputIterator> -vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, +vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type*) + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1084,11 +1108,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c template <class _Tp, class _Allocator> template <class _ForwardIterator> -vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, +vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type*) + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1154,7 +1179,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __base(_VSTD::move(__x.__alloc())) @@ -1170,7 +1195,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) { @@ -1197,7 +1222,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1211,7 +1236,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { @@ -1228,7 +1253,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) _NOEXCEPT_( @@ -1272,7 +1297,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) { @@ -1361,7 +1386,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { @@ -1373,7 +1398,7 @@ vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { @@ -1385,7 +1410,7 @@ vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { @@ -1393,7 +1418,7 @@ vector<_Tp, _Allocator>::begin() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT { @@ -1401,7 +1426,7 @@ vector<_Tp, _Allocator>::begin() const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { @@ -1409,7 +1434,7 @@ vector<_Tp, _Allocator>::end() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT { @@ -1417,7 +1442,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) { @@ -1426,7 +1451,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::operator[](size_type __n) const { @@ -1504,7 +1529,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) { @@ -1521,7 +1546,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -1553,7 +1578,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template <class _Tp, class _Allocator> template <class... _Args> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -1572,7 +1597,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::pop_back() { @@ -1581,7 +1606,7 @@ vector<_Tp, _Allocator>::pop_back() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) { @@ -1991,7 +2016,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __ #endif // _LIBCPP_DEBUG_LEVEL >= 2 template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_all_iterators() { @@ -2026,21 +2051,8 @@ public: typedef size_type __storage_type; typedef __bit_iterator<vector, false> pointer; typedef __bit_iterator<vector, true> const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter<vector, pointer> iterator; - typedef __debug_iter<vector, const_pointer> const_iterator; - - friend class __debug_iter<vector, pointer>; - friend class __debug_iter<vector, const_pointer>; - - pair<iterator*, const_iterator*> __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} -#else // _LIBCPP_DEBUG typedef pointer iterator; typedef const_pointer const_iterator; -#endif // _LIBCPP_DEBUG typedef _VSTD::reverse_iterator<iterator> reverse_iterator; typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; @@ -2092,6 +2104,9 @@ public: _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); ~vector(); explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const value_type& __v); vector(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIterator> @@ -2299,14 +2314,6 @@ private: _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_type __pos) const _NOEXCEPT {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} -#ifdef _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) - {return iterator(this, pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_type __pos) const - {return const_iterator(this, const_pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) - {return iterator(this, pointer(const_cast<__storage_pointer>(__p.base().__seg_), __p.base().__ctz_));} -#else // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} @@ -2316,7 +2323,6 @@ private: _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} -#endif // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __v) @@ -2387,16 +2393,10 @@ private: }; template <class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void vector<bool, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG } // Allocate space for __n objects @@ -2444,7 +2444,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<bool, _Allocator>::size_type vector<bool, _Allocator>::__recommend(size_type __new_size) const { @@ -2462,7 +2462,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { @@ -2486,7 +2486,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __begin_(nullptr), @@ -2496,7 +2496,7 @@ vector<bool, _Allocator>::vector() } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2517,6 +2517,21 @@ vector<bool, _Allocator>::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Allocator> +vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) + : __begin_(nullptr), + __size_(0), + __cap_alloc_(0, static_cast<__storage_allocator>(__a)) +{ + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n, false); + } +} +#endif + template <class _Allocator> vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) : __begin_(nullptr), @@ -2666,9 +2681,7 @@ vector<bool, _Allocator>::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); -#ifdef _LIBCPP_DEBUG __invalidate_all_iterators(); -#endif } template <class _Allocator> @@ -2721,7 +2734,7 @@ vector<bool, _Allocator>::operator=(const vector& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __begin_(__v.__begin_), @@ -2755,7 +2768,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a) } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(vector&& __v) _NOEXCEPT_( @@ -3042,7 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<bool, _Allocator>::iterator vector<bool, _Allocator>::erase(const_iterator __position) { @@ -3073,10 +3086,6 @@ vector<bool, _Allocator>::swap(vector& __x) _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); __swap_alloc(this->__alloc(), __x.__alloc()); -#ifdef _LIBCPP_DEBUG - iterator::swap(this, &__x); - const_iterator::swap(this, &__x); -#endif // _LIBCPP_DEBUG } template <class _Allocator> @@ -3175,7 +3184,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<vector<bool, _Allocator> > }; template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3184,7 +3193,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3192,7 +3201,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3200,7 +3209,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3208,7 +3217,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3216,7 +3225,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3224,7 +3233,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/external/bsd/libc++/dist/libcxx/src/algorithm.cpp b/external/bsd/libc++/dist/libcxx/src/algorithm.cpp index 6d5cf7c0bc8..10c4c331259 100644 --- a/external/bsd/libc++/dist/libcxx/src/algorithm.cpp +++ b/external/bsd/libc++/dist/libcxx/src/algorithm.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #include "algorithm" #include "random" #include "mutex" diff --git a/external/bsd/libc++/dist/libcxx/src/debug.cpp b/external/bsd/libc++/dist/libcxx/src/debug.cpp index c9b09b7a540..d0e867957dc 100644 --- a/external/bsd/libc++/dist/libcxx/src/debug.cpp +++ b/external/bsd/libc++/dist/libcxx/src/debug.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_DEBUG2 1 +#define _LIBCPP_DEBUG 1 #include "__config" #include "__debug" #include "functional" @@ -118,20 +118,19 @@ void __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); - __i_node* i = __insert_iterator(__i); - const char* errmsg = - "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"; - _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg); + if (__cbeg_ == __cend_) + return; size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; } + __i_node* i = __insert_iterator(__i); c->__add(i); i->__c_ = c; } @@ -217,18 +216,23 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A"); - while (p->__c_ != __c) - { - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all B"); - } - while (p->end_ != p->beg_) + if (__cend_ != __cbeg_) { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + while (p->__c_ != __c) + { + p = p->__next_; + if (p == nullptr) + return; + } + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } } } @@ -236,13 +240,26 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); + if (__cend_ == __cbeg_) + { + mut().unlock(); + return nullptr; + } size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } while (p->__c_ != __c) { p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } } return p; } @@ -271,28 +288,35 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - __c_node* q = nullptr; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); - while (p->__c_ != __c) + if (__cend_ != __cbeg_) { - q = p; - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); - } - if (q == nullptr) - __cbeg_[hc] = p->__next_; - else - q->__next_ = p->__next_; - while (p->end_ != p->beg_) - { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + __c_node* q = nullptr; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); + while (p->__c_ != __c) + { + q = p; + p = p->__next_; + if (p == nullptr) + return; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); + } + if (q == nullptr) + __cbeg_[hc] = p->__next_; + else + q->__next_ = p->__next_; + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } + free(p->beg_); + free(p); + --__csz_; } - free(p->beg_); - free(p); - --__csz_; } void diff --git a/external/bsd/libc++/dist/libcxx/src/exception.cpp b/external/bsd/libc++/dist/libcxx/src/exception.cpp index d3e1b292d34..9dbb1fae790 100644 --- a/external/bsd/libc++/dist/libcxx/src/exception.cpp +++ b/external/bsd/libc++/dist/libcxx/src/exception.cpp @@ -10,6 +10,7 @@ #include <stdio.h> #include "exception" +#include "new" #ifndef __has_include #define __has_include(inc) 0 @@ -90,14 +91,14 @@ terminate() _NOEXCEPT (*get_terminate())(); // handler should not return printf("terminate_handler unexpectedly returned\n"); - ::abort (); + ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception printf("terminate_handler unexpectedly threw an exception\n"); - ::abort (); + ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS } @@ -111,12 +112,17 @@ bool uncaught_exception() _NOEXCEPT // on Darwin, there is a helper function so __cxa_get_globals is private return __cxa_uncaught_exception(); #else // __APPLE__ - #warning uncaught_exception not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("uncaught_exception not yet implemented") +# else +# warning uncaught_exception not yet implemented +# endif printf("uncaught_exception not yet implemented\n"); ::abort(); #endif // __APPLE__ } + #ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT @@ -143,16 +149,50 @@ const char* bad_exception::what() const _NOEXCEPT #endif +#if defined(__GLIBCXX__) + +// libsupc++ does not implement the dependent EH ABI and the functionality +// it uses to implement std::exception_ptr (which it declares as an alias of +// std::__exception_ptr::exception_ptr) is not directly exported to clients. So +// we have little choice but to hijack std::__exception_ptr::exception_ptr's +// (which fortunately has the same layout as our std::exception_ptr) copy +// constructor, assignment operator and destructor (which are part of its +// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) +// function. + +namespace __exception_ptr +{ + +struct exception_ptr +{ + void* __ptr_; + + exception_ptr(const exception_ptr&) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; +}; + +} + +_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); + +#endif exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_decrement_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT @@ -160,11 +200,18 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_increment_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr( + reinterpret_cast<const __exception_ptr::exception_ptr&>(other)); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT @@ -177,11 +224,19 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT __ptr_ = other.__ptr_; } return *this; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + *reinterpret_cast<__exception_ptr::exception_ptr*>(this) = + reinterpret_cast<const __exception_ptr::exception_ptr&>(other); + return *this; +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } nested_exception::nested_exception() _NOEXCEPT @@ -189,10 +244,14 @@ nested_exception::nested_exception() _NOEXCEPT { } +#if !defined(__GLIBCXX__) + nested_exception::~nested_exception() _NOEXCEPT { } +#endif + _LIBCPP_NORETURN void nested_exception::rethrow_nested() const @@ -202,6 +261,7 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } +#if !defined(__GLIBCXX__) exception_ptr current_exception() _NOEXCEPT { @@ -212,13 +272,19 @@ exception_ptr current_exception() _NOEXCEPT exception_ptr ptr; ptr.__ptr_ = __cxa_current_primary_exception(); return ptr; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING( "exception_ptr not yet implemented" ) +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } +#endif // !__GLIBCXX__ + _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { @@ -226,10 +292,16 @@ void rethrow_exception(exception_ptr p) __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } } // std diff --git a/external/bsd/libc++/dist/libcxx/src/future.cpp b/external/bsd/libc++/dist/libcxx/src/future.cpp index 7d9a5b5da69..70919ab7df8 100644 --- a/external/bsd/libc++/dist/libcxx/src/future.cpp +++ b/external/bsd/libc++/dist/libcxx/src/future.cpp @@ -26,11 +26,15 @@ __future_error_category::name() const _NOEXCEPT return "future"; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch" + string __future_error_category::message(int ev) const { switch (static_cast<future_errc>(ev)) { + case future_errc(0): // For backwards compatibility with C++11 (LWG 2056) case future_errc::broken_promise: return string("The associated promise has been destructed prior " "to the associated state becoming ready."); @@ -46,6 +50,8 @@ __future_error_category::message(int ev) const return string("unspecified future_errc value\n"); } +#pragma clang diagnostic pop + const error_category& future_category() _NOEXCEPT { diff --git a/external/bsd/libc++/dist/libcxx/src/ios.cpp b/external/bsd/libc++/dist/libcxx/src/ios.cpp index 732a61bb239..bbe3c072e67 100644 --- a/external/bsd/libc++/dist/libcxx/src/ios.cpp +++ b/external/bsd/libc++/dist/libcxx/src/ios.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "ios" #include "streambuf" #include "istream" @@ -61,7 +63,7 @@ __iostream_category::message(int ev) const } const error_category& -iostream_category() +iostream_category() _NOEXCEPT { static __iostream_category s; return s; @@ -147,8 +149,11 @@ ios_base::getloc() const } // xalloc - +#if __has_feature(cxx_atomic) +atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0); +#else int ios_base::__xindex_ = 0; +#endif int ios_base::xalloc() diff --git a/external/bsd/libc++/dist/libcxx/src/locale.cpp b/external/bsd/libc++/dist/libcxx/src/locale.cpp index ac1952151a0..8fadbb6fdfd 100644 --- a/external/bsd/libc++/dist/libcxx/src/locale.cpp +++ b/external/bsd/libc++/dist/libcxx/src/locale.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + // On Solaris, we need to define something to make the C99 parts of localeconv // visible. #ifdef __sun__ @@ -26,7 +28,7 @@ #include "cstring" #include "cwctype" #include "__sso_allocator" -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> #else // _LIBCPP_MSVCRT #include <langinfo.h> @@ -36,7 +38,9 @@ // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. +#if defined(__clang__) #pragma clang diagnostic ignored "-Wsign-conversion" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -107,6 +111,11 @@ countof(const T * const begin, const T * const end) } +#if defined(_AIX) +// Set priority to INT_MIN + 256 + 150 +# pragma priority ( -2147483242 ) +#endif + const locale::category locale::none; const locale::category locale::collate; const locale::category locale::ctype; @@ -116,14 +125,23 @@ const locale::category locale::time; const locale::category locale::messages; const locale::category locale::all; +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif class _LIBCPP_HIDDEN locale::__imp : public facet { enum {N = 28}; +#if defined(_LIBCPP_MSVC) +// FIXME: MSVC doesn't support aligned parameters by value. +// I can't get the __sso_allocator to work here +// for MSVC I think for this reason. + vector<facet*> facets_; +#else vector<facet*, __sso_allocator<facet*, N> > facets_; +#endif string name_; public: explicit __imp(size_t refs = 0); @@ -147,7 +165,9 @@ private: template <class F> void install_from(const __imp& other); }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif locale::__imp::__imp(size_t refs) : facet(refs), @@ -757,7 +777,7 @@ ctype<wchar_t>::~ctype() bool ctype<wchar_t>::do_is(mask m, char_type c) const { - return isascii(c) ? ctype<char>::classic_table()[c] & m : false; + return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false; } const wchar_t* @@ -1009,7 +1029,7 @@ ctype<char>::classic_table() _NOEXCEPT return __cloc()->__ctype_b; #elif __sun__ return __ctype_mask; -#elif defined(_LIBCPP_MSVCRT) +#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) return _ctype+1; // internal ctype mask table defined in msvcrt.dll // This is assumed to be safe, which is a nonsense assumption because we're // going to end up dereferencing it later... @@ -4352,7 +4372,7 @@ __num_put_base::__format_float(char* __fmtp, const char* __len, if (__flags & ios_base::showpoint) *__fmtp++ = '#'; ios_base::fmtflags floatfield = __flags & ios_base::floatfield; - bool uppercase = __flags & ios_base::uppercase; + bool uppercase = (__flags & ios_base::uppercase) != 0; if (floatfield == (ios_base::fixed | ios_base::scientific)) specify_precision = false; else @@ -4683,9 +4703,12 @@ __time_get::~__time_get() { freelocale(__loc_); } - +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-field-initializers" +#endif +#if defined(__GNUG__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif template <> string @@ -4831,7 +4854,9 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) return result; } +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-braces" +#endif template <> wstring @@ -5850,7 +5875,7 @@ moneypunct_byname<char, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -5858,7 +5883,7 @@ moneypunct_byname<char, true>::init(const char* nm) __positive_sign_ = "()"; else __positive_sign_ = lc->positive_sign; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if(lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -5870,7 +5895,7 @@ moneypunct_byname<char, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' '); __init_pat(__neg_format_, __curr_symbol_, true, @@ -6009,7 +6034,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -6029,7 +6054,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) wbe = wbuf + j; __positive_sign_.assign(wbuf, wbe); } -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -6053,7 +6078,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' '); __init_pat(__neg_format_, __curr_symbol_, true, diff --git a/external/bsd/libc++/dist/libcxx/src/mutex.cpp b/external/bsd/libc++/dist/libcxx/src/mutex.cpp index 42195aa8064..07678978a67 100644 --- a/external/bsd/libc++/dist/libcxx/src/mutex.cpp +++ b/external/bsd/libc++/dist/libcxx/src/mutex.cpp @@ -42,6 +42,7 @@ void mutex::unlock() _NOEXCEPT { int ec = pthread_mutex_unlock(&__m_); + (void)ec; assert(ec == 0); } @@ -79,6 +80,7 @@ fail: recursive_mutex::~recursive_mutex() { int e = pthread_mutex_destroy(&__m_); + (void)e; assert(e == 0); } @@ -94,6 +96,7 @@ void recursive_mutex::unlock() _NOEXCEPT { int e = pthread_mutex_unlock(&__m_); + (void)e; assert(e == 0); } diff --git a/external/bsd/libc++/dist/libcxx/src/new.cpp b/external/bsd/libc++/dist/libcxx/src/new.cpp index b23a516ff37..fa0331a8b71 100644 --- a/external/bsd/libc++/dist/libcxx/src/new.cpp +++ b/external/bsd/libc++/dist/libcxx/src/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include <stdlib.h> #include "new" @@ -28,16 +30,18 @@ #if defined(LIBCXXRT) || __has_include(<cxxabi.h>) #include <cxxabi.h> #endif // __has_include(<cxxabi.h>) - #ifndef _LIBCPPABI_VERSION + #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif +#ifndef __GLIBCXX__ + // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overriden by programs // that define non-weak copies of the functions. -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) @@ -64,7 +68,7 @@ operator new(std::size_t size) return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -83,7 +87,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) @@ -93,7 +97,7 @@ operator new[](size_t size) return ::operator new(size); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -112,7 +116,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr) _NOEXCEPT { @@ -120,34 +124,40 @@ operator delete(void* ptr) _NOEXCEPT ::free(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } +#endif // !__GLIBCXX__ + namespace std { +#ifndef __GLIBCXX__ const nothrow_t nothrow = {}; +#endif #ifndef _LIBCPPABI_VERSION +#ifndef __GLIBCXX__ + new_handler set_new_handler(new_handler handler) _NOEXCEPT { @@ -160,12 +170,16 @@ get_new_handler() _NOEXCEPT return __sync_fetch_and_add(&__new_handler, (new_handler)0); } +#endif // !__GLIBCXX__ + #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } +#ifndef __GLIBCXX__ + bad_alloc::~bad_alloc() _NOEXCEPT { } @@ -176,6 +190,8 @@ bad_alloc::what() const _NOEXCEPT return "std::bad_alloc"; } +#endif // !__GLIBCXX__ + #endif //LIBCXXRT bad_array_new_length::bad_array_new_length() _NOEXCEPT @@ -187,12 +203,28 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT } const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + +const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION + +#ifndef LIBSTDCXX void __throw_bad_alloc() @@ -202,4 +234,6 @@ __throw_bad_alloc() #endif } +#endif // !LIBSTDCXX + } // std diff --git a/external/bsd/libc++/dist/libcxx/src/optional.cpp b/external/bsd/libc++/dist/libcxx/src/optional.cpp new file mode 100644 index 00000000000..fde071c9a13 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/src/optional.cpp @@ -0,0 +1,25 @@ +//===------------------------ optional.cpp --------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include "optional" + +namespace std // purposefully not using versioning namespace +{ + +#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + +bad_optional_access::~bad_optional_access() _NOEXCEPT {} + +#else + +bad_optional_access::~bad_optional_access() _NOEXCEPT = default; + +#endif + +} // std diff --git a/external/bsd/libc++/dist/libcxx/src/random.cpp b/external/bsd/libc++/dist/libcxx/src/random.cpp index 97a40c509dc..47cdee402b7 100644 --- a/external/bsd/libc++/dist/libcxx/src/random.cpp +++ b/external/bsd/libc++/dist/libcxx/src/random.cpp @@ -7,6 +7,12 @@ // //===----------------------------------------------------------------------===// +#if defined(_WIN32) +// Must be defined before including stdlib.h to enable rand_s(). +#define _CRT_RAND_S +#include <stdio.h> +#endif + #include "random" #include "system_error" @@ -19,6 +25,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_WIN32) +random_device::random_device(const string&) +{ +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + errno_t err = rand_s(&r); + if (err) + __throw_system_error(err, "random_device rand_s failed."); + return r; +} +#else random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { @@ -38,6 +63,7 @@ random_device::operator()() read(__f_, &r, sizeof(r)); return r; } +#endif // defined(_WIN32) double random_device::entropy() const _NOEXCEPT diff --git a/external/bsd/libc++/dist/libcxx/src/shared_mutex.cpp b/external/bsd/libc++/dist/libcxx/src/shared_mutex.cpp new file mode 100644 index 00000000000..5fb22e44544 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/src/shared_mutex.cpp @@ -0,0 +1,101 @@ +//===---------------------- shared_mutex.cpp ------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#define _LIBCPP_BUILDING_SHARED_MUTEX +#include "shared_mutex" + +_LIBCPP_BEGIN_NAMESPACE_STD + +shared_mutex::shared_mutex() + : __state_(0) +{ +} + +// Exclusive ownership + +void +shared_mutex::lock() +{ + unique_lock<mutex> lk(__mut_); + while (__state_ & __write_entered_) + __gate1_.wait(lk); + __state_ |= __write_entered_; + while (__state_ & __n_readers_) + __gate2_.wait(lk); +} + +bool +shared_mutex::try_lock() +{ + unique_lock<mutex> lk(__mut_); + if (__state_ == 0) + { + __state_ = __write_entered_; + return true; + } + return false; +} + +void +shared_mutex::unlock() +{ + lock_guard<mutex> _(__mut_); + __state_ = 0; + __gate1_.notify_all(); +} + +// Shared ownership + +void +shared_mutex::lock_shared() +{ + unique_lock<mutex> lk(__mut_); + while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + __gate1_.wait(lk); + unsigned num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; +} + +bool +shared_mutex::try_lock_shared() +{ + unique_lock<mutex> lk(__mut_); + unsigned num_readers = __state_ & __n_readers_; + if (!(__state_ & __write_entered_) && num_readers != __n_readers_) + { + ++num_readers; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + return true; + } + return false; +} + +void +shared_mutex::unlock_shared() +{ + lock_guard<mutex> _(__mut_); + unsigned num_readers = (__state_ & __n_readers_) - 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + if (__state_ & __write_entered_) + { + if (num_readers == 0) + __gate2_.notify_one(); + } + else + { + if (num_readers == __n_readers_ - 1) + __gate1_.notify_one(); + } +} + + +_LIBCPP_END_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/src/stdexcept.cpp b/external/bsd/libc++/dist/libcxx/src/stdexcept.cpp index 8d25f3ee542..a4207d6058f 100644 --- a/external/bsd/libc++/dist/libcxx/src/stdexcept.cpp +++ b/external/bsd/libc++/dist/libcxx/src/stdexcept.cpp @@ -28,7 +28,9 @@ // Note: optimize for size +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility push(hidden) +#endif namespace { @@ -47,9 +49,9 @@ private: count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));} public: explicit __libcpp_nmstr(const char* msg); - __libcpp_nmstr(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW; - __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW; - ~__libcpp_nmstr() _LIBCPP_CANTTHROW; + __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT; + __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT; + ~__libcpp_nmstr(); const char* c_str() const _NOEXCEPT {return str_;} }; @@ -65,14 +67,14 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg) } inline -__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) +__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT : str_(s.str_) { __sync_add_and_fetch(&count(), 1); } __libcpp_nmstr& -__libcpp_nmstr::operator=(const __libcpp_nmstr& s) +__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT { const char* p = str_; str_ = s.str_; @@ -91,7 +93,9 @@ __libcpp_nmstr::~__libcpp_nmstr() } +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility pop +#endif namespace std // purposefully not using versioning namespace { @@ -123,7 +127,7 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) logic_error::~logic_error() _NOEXCEPT { @@ -167,7 +171,7 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) runtime_error::~runtime_error() _NOEXCEPT { diff --git a/external/bsd/libc++/dist/libcxx/src/string.cpp b/external/bsd/libc++/dist/libcxx/src/string.cpp index 5a86911654d..fde52129e9f 100644 --- a/external/bsd/libc++/dist/libcxx/src/string.cpp +++ b/external/bsd/libc++/dist/libcxx/src/string.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "string" #include "cstdlib" #include "cwchar" @@ -89,7 +91,7 @@ inline int as_integer(const string& func, const string& s, size_t* idx, int base ) { - // Use long as no Stantard string to integer exists. + // Use long as no Standard string to integer exists. long r = as_integer_helper<long>( func, s, idx, base, strtol ); if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r) throw_from_string_out_of_range(func); diff --git a/external/bsd/libc++/dist/libcxx/src/strstream.cpp b/external/bsd/libc++/dist/libcxx/src/strstream.cpp index 08a78a74f6c..c1965ea3762 100644 --- a/external/bsd/libc++/dist/libcxx/src/strstream.cpp +++ b/external/bsd/libc++/dist/libcxx/src/strstream.cpp @@ -229,8 +229,8 @@ strstreambuf::pos_type strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; bool legal = false; switch (__way) { @@ -287,8 +287,8 @@ strstreambuf::pos_type strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; if (pos_in || pos_out) { if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr))) diff --git a/external/bsd/libc++/dist/libcxx/src/system_error.cpp b/external/bsd/libc++/dist/libcxx/src/system_error.cpp index 7376b770ecf..b40409f854a 100644 --- a/external/bsd/libc++/dist/libcxx/src/system_error.cpp +++ b/external/bsd/libc++/dist/libcxx/src/system_error.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" #include "string" #include "cstring" diff --git a/external/bsd/libc++/dist/libcxx/src/thread.cpp b/external/bsd/libc++/dist/libcxx/src/thread.cpp index cdfa2fd9273..338a8a24cef 100644 --- a/external/bsd/libc++/dist/libcxx/src/thread.cpp +++ b/external/bsd/libc++/dist/libcxx/src/thread.cpp @@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT #else // defined(CTL_HW) && defined(HW_NCPU) // TODO: grovel through /proc or check cpuid on x86 and similar // instructions on other architectures. -#warning hardware_concurrency not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("hardware_concurrency not yet implemented") +# else +# warning hardware_concurrency not yet implemented +# endif return 0; // Means not computable [thread.thread.static] #endif // defined(CTL_HW) && defined(HW_NCPU) } diff --git a/external/bsd/libc++/dist/libcxx/src/typeinfo.cpp b/external/bsd/libc++/dist/libcxx/src/typeinfo.cpp index 60828944a1b..b4281209170 100644 --- a/external/bsd/libc++/dist/libcxx/src/typeinfo.cpp +++ b/external/bsd/libc++/dist/libcxx/src/typeinfo.cpp @@ -20,12 +20,18 @@ #include "typeinfo" -#if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT)) +#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) std::bad_cast::bad_cast() _NOEXCEPT { } +std::bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +#ifndef __GLIBCXX__ + std::bad_cast::~bad_cast() _NOEXCEPT { } @@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT return "std::bad_cast"; } -std::bad_typeid::bad_typeid() _NOEXCEPT -{ -} - std::bad_typeid::~bad_typeid() _NOEXCEPT { } @@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT } #endif -#endif // _LIBCPPABI_VERSION +#endif // !__GLIBCXX__ +#endif // !LIBCXXRT && !_LIBCPPABI_VERSION diff --git a/external/bsd/libc++/dist/libcxx/src/valarray.cpp b/external/bsd/libc++/dist/libcxx/src/valarray.cpp index 2d8db52ac36..e4c9ed02462 100644 --- a/external/bsd/libc++/dist/libcxx/src/valarray.cpp +++ b/external/bsd/libc++/dist/libcxx/src/valarray.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "valarray" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/external/bsd/libc++/dist/libcxx/test/CMakeLists.txt b/external/bsd/libc++/dist/libcxx/test/CMakeLists.txt index 496ba3d8072..4810b2c5748 100644 --- a/external/bsd/libc++/dist/libcxx/test/CMakeLists.txt +++ b/external/bsd/libc++/dist/libcxx/test/CMakeLists.txt @@ -8,7 +8,12 @@ endmacro() include(FindPythonInterp) if(PYTHONINTERP_FOUND) - set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.") + if(LIBCXX_BUILT_STANDALONE) + set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.") + else() + set(LIT_EXECUTABLE "${CMAKE_SOURCE_DIR}/utils/lit/lit.py") + endif() + set(LIT_ARGS_DEFAULT "-sv") if (MSVC OR XCODE) set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") @@ -19,7 +24,7 @@ if(PYTHONINTERP_FOUND) separate_arguments(LIT_ARGS) set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) - set(LIBCXX_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR}) set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) pythonize_bool(LIBCXX_ENABLE_SHARED) @@ -37,7 +42,7 @@ if(PYTHONINTERP_FOUND) ${LIT_EXECUTABLE} ${LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS + DEPENDS cxx COMMENT "Running libcxx tests") else() message(WARNING "Could not find Python, no check target will be available!") diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp index 14e0eb3d4f7..d844624560e 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp @@ -69,6 +69,32 @@ int main() assert(m.key_comp() == C(3)); assert(m.get_allocator() == A()); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + typedef min_allocator<V> A; + typedef test_compare<std::less<int> > C; + typedef std::map<int, double, C, A> M; + A a; + M m ({ {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, a); + + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.get_allocator() == a); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index 8fabdcc087d..2c767123af1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -75,5 +75,34 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef std::pair<const int, double> V; + typedef min_allocator<V> A; + typedef test_compare<std::less<int> > C; + A a; + std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a ); + + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.get_allocator() == a); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp index 3f4073be082..a2c0cdb858d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp @@ -92,5 +92,38 @@ int main() assert(m.key_comp() == Cmp(4)); assert(m.get_allocator() == A()); } +#if _LIBCPP_STD_VER > 11 + { + typedef test_compare<std::less<int> > C; + typedef std::pair<const int, double> V; + typedef min_allocator<V> A; + typedef std::multimap<int, double, C, A> M; + A a; + M m ({ {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, a); + + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + M::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + assert(m.get_allocator() == a); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp index 3095cb56f33..78fdbdb2022 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp @@ -76,5 +76,37 @@ int main() assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef min_allocator<std::pair<const int, double>> A; + A a; + std::multimap<int, double, std::less<int>, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + assert(m.get_allocator() == a); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/scary.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/scary.pass.cpp new file mode 100644 index 00000000000..b99d9bc2df9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multimap/scary.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class map class multimap + +// Extension: SCARY/N2913 iterator compatibility between map and multimap + +#include <map> + +int main() +{ + typedef std::map<int, int> M1; + typedef std::multimap<int, int> M2; + M2::iterator i; + M1::iterator j = i; +} diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp index 9e3186d9233..60e6940e723 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp @@ -51,5 +51,23 @@ int main() assert(*++i == V(5)); assert(*++i == V(6)); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::multiset<int, std::less<int>, min_allocator<int>> C; + typedef C::value_type V; + min_allocator<int> a; + C m ({1, 2, 3, 4, 5, 6}, a); + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + assert(m.get_allocator() == a); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp index a83e2ae581d..b6d25d6ec5f 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp @@ -55,4 +55,38 @@ int main() assert(*next(m.begin(), 6) == 3); assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); +#if _LIBCPP_STD_VER > 11 + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + typedef test_allocator<V> A; + typedef test_compare<std::less<int> > C; + A a; + std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a); + + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 1); + assert(*next(m.begin(), 2) == 1); + assert(*next(m.begin(), 3) == 2); + assert(*next(m.begin(), 4) == 2); + assert(*next(m.begin(), 5) == 2); + assert(*next(m.begin(), 6) == 3); + assert(*next(m.begin(), 7) == 3); + assert(*next(m.begin(), 8) == 3); + assert(m.get_allocator() == a); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/scary.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/scary.pass.cpp new file mode 100644 index 00000000000..f5ee32714e8 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/multiset/scary.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <set> + +// class set class multiset + +// Extension: SCARY/N2913 iterator compatibility between set and multiset + +#include <set> + +int main() +{ + typedef std::set<int> M1; + typedef std::multiset<int> M2; + M2::iterator i; + M1::iterator j = i; +} diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp index c180915aec8..d4021acfc30 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp @@ -12,6 +12,7 @@ // class set // set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); +// set(initializer_list<value_type> il, const allocator_type& a); #include <set> #include <cassert> @@ -21,6 +22,7 @@ int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef test_compare<std::less<int> > Cmp; typedef test_allocator<int> A; typedef std::set<int, Cmp, A> C; @@ -37,5 +39,25 @@ int main() assert(*++i == V(6)); assert(m.key_comp() == Cmp(10)); assert(m.get_allocator() == A(4)); + } +#if _LIBCPP_STD_VER > 11 + { + typedef test_compare<std::less<int> > Cmp; + typedef test_allocator<int> A; + typedef std::set<int, Cmp, A> C; + typedef C::value_type V; + C m({1, 2, 3, 4, 5, 6}, A(4)); + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + assert(m.get_allocator() == A(4)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp index 9b4992bdb09..1ae4634a5b7 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp @@ -14,6 +14,10 @@ // template <class InputIterator> // set(InputIterator first, InputIterator last, // const value_compare& comp, const allocator_type& a); +// +// template <class InputIterator> +// set(InputIterator first, InputIterator last, +// const allocator_type& a); #include <set> #include <cassert> @@ -49,4 +53,32 @@ int main() assert(*m.begin() == 1); assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); +#if _LIBCPP_STD_VER > 11 + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + typedef test_allocator<V> A; + typedef test_compare<std::less<int> > C; + A a(7); + std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a); + + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + assert(m.get_allocator() == a); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp index 6d0bf424829..1f07caf4860 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp @@ -20,7 +20,29 @@ template <class T, class Allocator> void -test(unsigned n) +test2(unsigned n) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::deque<T, Allocator> C; + typedef typename C::const_iterator const_iterator; + assert(DefaultOnly::count == 0); + { + C d(n, Allocator()); + assert(DefaultOnly::count == n); + assert(d.size() == n); + assert(distance(d.begin(), d.end()) == d.size()); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) + assert(*i == T()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } + assert(DefaultOnly::count == 0); +#endif +} + +template <class T, class Allocator> +void +test1(unsigned n) { typedef std::deque<T, Allocator> C; typedef typename C::const_iterator const_iterator; @@ -38,6 +60,29 @@ test(unsigned n) assert(DefaultOnly::count == 0); } +template <class T, class Allocator> +void +test3(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::deque<T, Allocator> C; + typedef typename C::const_iterator const_iterator; + { + C d(n, alloc); + assert(d.size() == n); + assert(d.get_allocator() == alloc); + } +#endif +} + +template <class T, class Allocator> +void +test(unsigned n) +{ + test1<T, Allocator> ( n ); + test2<T, Allocator> ( n ); +} + int main() { test<DefaultOnly, std::allocator<DefaultOnly> >(0); @@ -52,8 +97,17 @@ int main() test<DefaultOnly, std::allocator<DefaultOnly> >(4095); test<DefaultOnly, std::allocator<DefaultOnly> >(4096); test<DefaultOnly, std::allocator<DefaultOnly> >(4097); - test<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095); + + test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095); + #if __cplusplus >= 201103L test<DefaultOnly, min_allocator<DefaultOnly> >(4095); #endif + +#if _LIBCPP_STD_VER > 11 + test3<DefaultOnly, std::allocator<DefaultOnly>> (1023); + test3<int, std::allocator<int>>(1); + test3<int, min_allocator<int>> (3); +#endif + } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp new file mode 100644 index 00000000000..cf8843d344a --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.cons + +// template <class Alloc> +// dynarray(size_type c, const Alloc& alloc); +// template <class Alloc> +// dynarray(size_type c, const T& v, const Alloc& alloc); +// template <class Alloc> +// dynarray(const dynarray& d, const Alloc& alloc); +// template <class Alloc> +// dynarray(initializer_list<T>, const Alloc& alloc); + +// ~dynarray(); + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> +#include "../../../test_allocator.h" + +template <class T, class Allocator> +void check_allocator ( const std::dynarray<T> &dyn, const Allocator &alloc ) { + for ( int i = 0; i < dyn.size (); ++i ) + assert ( dyn[i].get_allocator() == alloc ); +} + +template <class T, class Allocator> +void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( vals, alloc ); + assert ( d1.size () == vals.size() ); + assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ())); + check_allocator ( d1, alloc ); + } + + +template <class T, class Allocator> +void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4, alloc1 ); + assert ( d1.size () == 4 ); + assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); + check_allocator ( d1, alloc1 ); + + dynA d2 ( 7, val, alloc1 ); + assert ( d2.size () == 7 ); + assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } )); + check_allocator ( d2, alloc1 ); + + dynA d3 ( d2, alloc2 ); + assert ( d3.size () == 7 ); + assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } )); + check_allocator ( d3, alloc2 ); + } + +int main() +{ +// This test is waiting on the resolution of LWG issue #2235 +// typedef test_allocator<char> Alloc; +// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr; +// +// test ( nstr("fourteen"), Alloc(3), Alloc(4) ); +// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6)); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp new file mode 100644 index 00000000000..db93f212a0c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.cons + +// explicit dynarray(size_type c); +// dynarray(size_type c, const T& v); +// dynarray(initializer_list<T>); +// dynarray(const dynarray& d); + +// ~dynarray(); + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void test ( const std::initializer_list<T> &vals ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( vals ); + assert ( d1.size () == vals.size() ); + assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ())); + } + + +template <class T> +void test ( const T &val ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4 ); + assert ( d1.size () == 4 ); + assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); + + dynA d2 ( 7, val ); + assert ( d2.size () == 7 ); + assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } )); + + dynA d3 ( d2 ); + assert ( d3.size () == 7 ); + assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } )); + } + +void test_bad_length () { + try { std::dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); } + catch ( std::bad_array_length & ) { return ; } + assert ( false ); + } + +void test_bad_alloc () { + try { std::dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); } + catch ( std::bad_alloc & ) { return ; } + assert ( false ); + } + +int main() +{ +// test<int> ( 14 ); // ints don't get default initialized + test<long> ( 0 ); + test<double> ( 14.0 ); + test<std::complex<double>> ( std::complex<double> ( 14, 0 )); + test<std::string> ( "fourteen" ); + + test ( { 1, 1, 2, 3, 5, 8 } ); + test ( { 1., 1., 2., 3., 5., 8. } ); + test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); + +// Make sure we don't pick up the Allocator version here + std::dynarray<long> d1 ( 20, 3 ); + assert ( d1.size() == 20 ); + assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } )); + + test_bad_length (); + test_bad_alloc (); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp new file mode 100644 index 00000000000..66c0fc56fac --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.data + +// T* data() noexcept; +// const T* data() const noexcept; + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + + +template <class T> +void dyn_test_const ( const std::dynarray<T> &dyn ) { + const T *data = dyn.data (); + assert ( data != NULL ); + assert ( std::equal ( dyn.begin(), dyn.end(), data )); + } + +template <class T> +void dyn_test ( std::dynarray<T> &dyn ) { + T *data = dyn.data (); + assert ( data != NULL ); + assert ( std::equal ( dyn.begin(), dyn.end(), data )); + } + + + +template <class T> +void test ( const T &val ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4 ); + dyn_test ( d1 ); + dyn_test_const ( d1 ); + + dynA d2 ( 7, val ); + dyn_test ( d2 ); + dyn_test_const ( d2 ); + } + +int main() +{ + test<int> ( 14 ); + test<double> ( 14.0 ); + test<std::complex<double>> ( std::complex<double> ( 14, 0 )); + test<std::string> ( "fourteen" ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp new file mode 100644 index 00000000000..57773414a41 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.data + +// void fill(const T& v); +// const T* data() const noexcept; + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + + +template <class T> +void test ( const T &val ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4 ); + d1.fill ( val ); + assert ( std::all_of ( d1.begin (), d1.end (), + [&val]( const T &item ){ return item == val; } )); + } + +int main() +{ + test<int> ( 14 ); + test<double> ( 14.0 ); + test<std::complex<double>> ( std::complex<double> ( 14, 0 )); + test<std::string> ( "fourteen" ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp new file mode 100644 index 00000000000..dca4ff80ce6 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + +// const_reference at(size_type n) const; +// reference at(size_type n); + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void dyn_at_fail ( std::dynarray<T> &dyn, size_t sz ) { + try { dyn.at (sz); } + catch (const std::out_of_range &) { return; } + assert ( false ); + } + +template <class T> +void dyn_at_fail_const ( const std::dynarray<T> &dyn, size_t sz ) { + try { dyn.at (sz); } + catch (const std::out_of_range &) { return; } + assert ( false ); + } + + +template <class T> +void dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) { + const T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn.at(i)); + assert ( *it == dyn.at(i)); + } + + dyn_at_fail_const ( dyn, dyn.size ()); + dyn_at_fail_const ( dyn, 2*dyn.size ()); + dyn_at_fail_const ( dyn, size_t (-1)); + } + +template <class T> +void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) { + T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn.at(i)); + assert ( *it == dyn.at(i)); + } + + dyn_at_fail ( dyn, dyn.size ()); + dyn_at_fail ( dyn, 2*dyn.size ()); + dyn_at_fail ( dyn, size_t (-1)); + } + + +template <class T> +void test ( std::initializer_list<T> vals ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( vals ); + dyn_test ( d1, vals ); + dyn_test_const ( d1, vals ); + } + +int main() +{ + test ( { 1, 1, 2, 3, 5, 8 } ); + test ( { 1., 1., 2., 3., 5., 8. } ); + test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); + + test<int> ( {} ); + test<std::complex<double>> ( {} ); + test<std::string> ( {} ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp new file mode 100644 index 00000000000..6bca0417222 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp @@ -0,0 +1,106 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + + +// iterator begin() noexcept; +// const_iterator begin() const noexcept; +// const_iterator cbegin() const noexcept; +// iterator end() noexcept; +// const_iterator end() const noexcept; +// const_iterator cend() const noexcept; +// +// reverse_iterator rbegin() noexcept; +// const_reverse_iterator rbegin() const noexcept; +// const_reverse_iterator crbegin() const noexcept; +// reverse_iterator rend() noexcept; +// const_reverse_iterator rend() const noexcept; +// const_reverse_iterator crend() const noexcept; + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void dyn_test_const ( const std::dynarray<T> &dyn ) { + const T *data = dyn.data (); + assert ( data == &*dyn.begin ()); + assert ( data == &*dyn.cbegin ()); + + assert ( data + dyn.size() - 1 == &*dyn.rbegin ()); + assert ( data + dyn.size() - 1 == &*dyn.crbegin ()); + + assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end())); + assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend())); + assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend())); + assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend())); + + assert ( dyn.begin () == dyn.cbegin ()); + assert ( &*dyn.begin () == &*dyn.cbegin ()); + assert ( dyn.rbegin () == dyn.crbegin ()); + assert ( &*dyn.rbegin () == &*dyn.crbegin ()); + assert ( dyn.end () == dyn.cend ()); + assert ( dyn.rend () == dyn.crend ()); + } + +template <class T> +void dyn_test ( std::dynarray<T> &dyn ) { + T *data = dyn.data (); + assert ( data == &*dyn.begin ()); + assert ( data == &*dyn.cbegin ()); + + assert ( data + dyn.size() - 1 == &*dyn.rbegin ()); + assert ( data + dyn.size() - 1 == &*dyn.crbegin ()); + + assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end())); + assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend())); + assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend())); + assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend())); + + assert ( dyn.begin () == dyn.cbegin ()); + assert ( &*dyn.begin () == &*dyn.cbegin ()); + assert ( dyn.rbegin () == dyn.crbegin ()); + assert ( &*dyn.rbegin () == &*dyn.crbegin ()); + assert ( dyn.end () == dyn.cend ()); + assert ( dyn.rend () == dyn.crend ()); + } + + +template <class T> +void test ( const T &val ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4 ); + dyn_test ( d1 ); + dyn_test_const ( d1 ); + + dynA d2 ( 7, val ); + dyn_test ( d2 ); + dyn_test_const ( d2 ); + } + +int main() +{ + test<int> ( 14 ); + test<double> ( 14.0 ); + test<std::complex<double>> ( std::complex<double> ( 14, 0 )); + test<std::string> ( "fourteen" ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp new file mode 100644 index 00000000000..acea76b8619 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + +// size_type size() const noexcept; +// size_type max_size() const noexcept; +// bool empty() const noexcept; + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void dyn_test ( const std::dynarray<T> &dyn, size_t sz ) { + assert ( dyn.size () == sz ); + assert ( dyn.max_size () == sz ); + assert ( dyn.empty () == ( sz == 0 )); + } + +template <class T> +void test ( std::initializer_list<T> vals ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( vals ); + dyn_test ( d1, vals.size ()); + } + +int main() +{ + test ( { 1, 1, 2, 3, 5, 8 } ); + test ( { 1., 1., 2., 3., 5., 8. } ); + test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); + + test<int> ( {} ); + test<std::complex<double>> ( {} ); + test<std::string> ( {} ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp new file mode 100644 index 00000000000..5cf3d20d850 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + +// reference front(); +// const_reference front() const; +// reference back(); +// const_reference back() const; + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void dyn_test_const ( const std::dynarray<T> &dyn ) { + const T *data = dyn.data (); + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + } + +template <class T> +void dyn_test ( std::dynarray<T> &dyn ) { + T *data = dyn.data (); + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + } + + +template <class T> +void test ( const T &val ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 4 ); + dyn_test ( d1 ); + dyn_test_const ( d1 ); + + dynA d2 ( 7, val ); + dyn_test ( d2 ); + dyn_test_const ( d2 ); + } + +int main() +{ + test<int> ( 14 ); + test<double> ( 14.0 ); + test<std::complex<double>> ( std::complex<double> ( 14, 0 )); + test<std::string> ( "fourteen" ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp new file mode 100644 index 00000000000..a396fbcdf36 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + +// const_reference at(size_type n) const; +// reference at(size_type n); + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + +template <class T> +void dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) { + const T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn[i]); + assert ( *it == dyn[i]); + } + } + +template <class T> +void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) { + T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn[i]); + assert ( *it == dyn[i]); + } + } + + +template <class T> +void test ( std::initializer_list<T> vals ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( vals ); + dyn_test ( d1, vals ); + dyn_test_const ( d1, vals ); + } + +int main() +{ + test ( { 1, 1, 2, 3, 5, 8 } ); + test ( { 1., 1., 2., 3., 5., 8. } ); + test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); + + test<int> ( {} ); + test<std::complex<double>> ( {} ); + test<std::string> ( {} ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp new file mode 100644 index 00000000000..baf551ee38b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// dynarray.data + +// template <class Type, class Alloc> +// struct uses_allocator<dynarray<Type>, Alloc> : true_type { }; + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include "../../../test_allocator.h" + +int main() +{ + static_assert ( std::uses_allocator<std::dynarray<int>, test_allocator<int>>::value, "" ); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp new file mode 100644 index 00000000000..1d94d487822 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.zero + +// dynarray shall provide support for the special case of construction with a size of zero. +// In the case that the size is zero, begin() == end() == unique value. +// The return value of data() is unspecified. +// The effect of calling front() or back() for a zero-sized dynarray is undefined. + + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <dynarray> +#include <cassert> + +#include <algorithm> +#include <complex> +#include <string> + + +template <class T> +void test ( ) { + typedef std::dynarray<T> dynA; + + dynA d1 ( 0 ); + assert ( d1.size() == 0 ); + assert ( d1.begin() == d1.end ()); + } + +int main() +{ + test<int> (); + test<double> (); + test<std::complex<double>> (); + test<std::string> (); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/nothing_to_do.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/dynarray/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index 1a9936818ec..fb71b318581 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -10,6 +10,7 @@ // <forward_list> // explicit forward_list(size_type n); +// explicit forward_list(size_type n, const Alloc& a); #include <forward_list> #include <cassert> @@ -17,6 +18,17 @@ #include "../../../DefaultOnly.h" #include "../../../min_allocator.h" +template <class T, class Allocator> +void check_allocator(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::forward_list<T, Allocator> C; + C d(n, alloc); + assert(d.get_allocator() == alloc); + assert(std::distance(d.begin(), d.end()) == n); +#endif +} + int main() { { @@ -47,6 +59,8 @@ int main() ; #endif assert(n == N); + check_allocator<T, min_allocator<T>> ( 0 ); + check_allocator<T, min_allocator<T>> ( 3 ); } #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_back.pass.cpp index 1cf9e4b395f..22a7eac4889 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_back.pass.cpp @@ -11,7 +11,7 @@ // Call back() on empty container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cback.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cback.pass.cpp index 55338f80475..613b4f1b818 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cback.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cback.pass.cpp @@ -11,7 +11,7 @@ // Call back() on empty const container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cfront.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cfront.pass.cpp index 9a36a5355ea..2646fe1d1ee 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cfront.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_cfront.pass.cpp @@ -11,7 +11,7 @@ // Call front() on empty const container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_front.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_front.pass.cpp index 39fcf244860..f7c3dfcf34a 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_front.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_front.pass.cpp @@ -11,7 +11,7 @@ // Call front() on empty container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_6.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_6.pass.cpp index c27c8d7a43a..9528d75dce1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_6.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_6.pass.cpp @@ -11,7 +11,7 @@ // Decrement iterator prior to begin. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_7.pass.cpp index 57bb317a9a9..795ffa7d46c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_8.pass.cpp index 9b09b77647a..2c347231b86 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_9.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_9.pass.cpp index 1437d615941..d02fcd6e449 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_9.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/db_iterators_9.pass.cpp @@ -11,7 +11,7 @@ // Operations on "NULL" iterators -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/move.pass.cpp index 2811a3e7997..f1c5a98f1b5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/move.pass.cpp @@ -61,7 +61,7 @@ int main() assert(l2.get_allocator() == lo.get_allocator()); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> l1 = {1, 2, 3}; std::list<int>::iterator i = l1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/size_type.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/size_type.pass.cpp index be17f06635f..864b5adcf8a 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.cons/size_type.pass.cpp @@ -17,6 +17,23 @@ #include "../../../stack_allocator.h" #include "../../../min_allocator.h" +template <class T, class Allocator> +void +test3(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::list<T, Allocator> C; + typedef typename C::const_iterator const_iterator; + { + C d(n, alloc); + assert(d.size() == n); + assert(std::distance(d.begin(), d.end()) == n); + assert(d.get_allocator() == alloc); + } +#endif +} + + int main() { { @@ -41,6 +58,21 @@ int main() ++i; assert(*i == 0); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::list<int, min_allocator<int> > C; + C l(3, min_allocator<int> ()); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + C::const_iterator i = l.begin(); + assert(*i == 0); + ++i; + assert(*i == 0); + ++i; + assert(*i == 0); + test3<int, min_allocator<int>> (3); + } +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<DefaultOnly> l(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/emplace.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/emplace.pass.cpp index 2347052ae3e..9f5edf5113d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/emplace.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/emplace.pass.cpp @@ -11,7 +11,7 @@ // template <class... Args> void emplace(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -51,7 +51,7 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<A> c1; std::list<A> c2; @@ -75,7 +75,7 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<A, min_allocator<A>> c1; std::list<A, min_allocator<A>> c2; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp index 1f4efbaa370..d5fd0449092 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp index 8f1397c03b7..df567aa6e52 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp index e4d5ca3c383..18b825beec4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp index 09ce820627c..84fbf375554 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp index b2d36f8acca..4bdee44faf3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp index f2ea2ae5f7e..5b1d3e1ac2f 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp index 1c5d2556966..9e23df3aa63 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp @@ -12,7 +12,7 @@ // template <InputIterator Iter> // iterator insert(const_iterator position, Iter first, Iter last); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -99,7 +99,7 @@ int main() assert(*i == 3); } throw_next = 0xFFFF; -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v(100); std::list<int> v2(100); @@ -167,7 +167,7 @@ int main() ++i; assert(*i == 3); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { throw_next = 0xFFFF; std::list<int, min_allocator<int>> v(100); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp index 40554a48a12..e575753e7fa 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, value_type&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -35,7 +35,7 @@ int main() assert(l1.back() == MoveOnly(1)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v1(3); std::list<int> v2(3); @@ -56,7 +56,7 @@ int main() assert(l1.back() == MoveOnly(1)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> v1(3); std::list<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp index 3566d1922d3..0de5a9f04fb 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, size_type n, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -62,7 +62,7 @@ int main() assert(save_count == count); assert(l1 == std::list<int>(a2, a2+8)); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> c1(100); std::list<int> c2; @@ -92,7 +92,7 @@ int main() assert(save_count == count); assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8))); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> c1(100); std::list<int, min_allocator<int>> c2; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp index 50aac8b5af9..bf9ed8b8770 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -64,7 +64,7 @@ int main() assert(save_count == count); assert(l1 == std::list<int>(a2, a2+4)); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v1(3); std::list<int> v2(3); @@ -97,7 +97,7 @@ int main() assert(save_count == count); assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4))); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> v1(3); std::list<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp index d7e8b61d602..a687b1b8fbb 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp @@ -11,7 +11,7 @@ // void pop_back(); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -31,7 +31,7 @@ int main() assert(c == std::list<int>(a, a+1)); c.pop_back(); assert(c.empty()); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); #endif @@ -46,7 +46,7 @@ int main() assert((c == std::list<int, min_allocator<int>>(a, a+1))); c.pop_back(); assert(c.empty()); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp index dee246dee58..81916e0fced 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp @@ -11,7 +11,7 @@ // void splice(const_iterator position, list& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -403,7 +403,7 @@ int main() ++i; assert(*i == 6); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v1(3); std::list<int> v2(3); @@ -791,7 +791,7 @@ int main() ++i; assert(*i == 6); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> v1(3); std::list<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp index 0f6caac9946..f4c04896fb0 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp @@ -11,7 +11,7 @@ // void splice(const_iterator position, list<T,Allocator>& x, iterator i); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -180,7 +180,7 @@ int main() ++i; assert(*i == 2); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v1(3); std::list<int> v2(3); @@ -345,7 +345,7 @@ int main() ++i; assert(*i == 2); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> v1(3); std::list<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp index 209fbb94f51..5745af5181f 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp @@ -11,7 +11,7 @@ // void splice(const_iterator position, list& x, iterator first, iterator last); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -120,7 +120,7 @@ int main() i = l2.begin(); assert(*i == 4); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int> v1(3); std::list<int> v2(3); @@ -225,7 +225,7 @@ int main() i = l2.begin(); assert(*i == 4); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::list<int, min_allocator<int>> v1(3); std::list<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.special/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.special/db_swap_1.pass.cpp index 9cb169055e2..e440f695f28 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.special/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/list/list.special/db_swap_1.pass.cpp @@ -12,7 +12,7 @@ // template <class T, class Alloc> // void swap(list<T,Alloc>& x, list<T,Alloc>& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -24,7 +24,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp index 0bbd36273f2..aa4ca0e27a4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp @@ -16,10 +16,27 @@ #include <cassert> #include "../../min_allocator.h" +#include "../../test_allocator.h" template <class C> void -test(typename C::size_type n) +test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) +{ +#if _LIBCPP_STD_VER > 11 + C c(n, a); + assert(c.__invariants()); + assert(c.size() == n); + assert(c.get_allocator() == a); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) + assert(*i == typename C::value_type()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif +} + +template <class C> +void +test1(typename C::size_type n) { C c(n); assert(c.__invariants()); @@ -29,10 +46,19 @@ test(typename C::size_type n) assert(*i == typename C::value_type()); } +template <class C> +void +test(typename C::size_type n) +{ + test1<C> ( n ); + test2<C> ( n ); +} + int main() { test<std::vector<bool> >(50); #if __cplusplus >= 201103L test<std::vector<bool, min_allocator<bool>> >(50); + test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23)); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_back.pass.cpp index 0893ba7a40d..05444528182 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_back.pass.cpp @@ -11,7 +11,7 @@ // Call back() on empty container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cback.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cback.pass.cpp index de52ec2e4cf..b8fd0326f20 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cback.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cback.pass.cpp @@ -11,7 +11,7 @@ // Call back() on empty const container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp index e0d9b950627..36ba0dd4792 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp @@ -11,7 +11,7 @@ // Call front() on empty const container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp index c96fa3da381..18ef2cfa815 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp @@ -11,7 +11,7 @@ // Index const vector out of bounds. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_front.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_front.pass.cpp index fb48c9d477a..97cdb2428de 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_front.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_front.pass.cpp @@ -11,7 +11,7 @@ // Call front() on empty container. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_index.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_index.pass.cpp index f09f731e237..785263b8ce3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_index.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_index.pass.cpp @@ -11,7 +11,7 @@ // Index vector out of bounds. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp index 436726c673e..26700027848 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp @@ -11,7 +11,7 @@ // Compare iterators from different containers with <. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp index ffd96d941aa..d47e3d456e1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp @@ -11,7 +11,7 @@ // Subtract iterators from different containers. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp index fbfae85eebb..bba222e31f1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp @@ -11,7 +11,7 @@ // Index iterator out of bounds. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp index 9ca5cbbd764..c5d96c520f2 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp @@ -11,7 +11,7 @@ // Add to iterator out of bounds. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp index d08506b4d3e..d33f29d0024 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp @@ -11,7 +11,7 @@ // Decrement iterator prior to begin. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp index 98c6d8bc4cf..25555b491da 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp index b8353948c8c..d891630a13f 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index e386297cf7a..afc8ea5d3d2 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -19,9 +19,9 @@ #include "../../../stack_allocator.h" #include "../../../min_allocator.h" -template <class C, class Iterator> +template <class C, class Iterator, class A> void -test(Iterator first, Iterator last, const typename C::allocator_type& a) +test(Iterator first, Iterator last, const A& a) { C c(first, last, a); assert(c.__invariants()); @@ -30,6 +30,17 @@ test(Iterator first, Iterator last, const typename C::allocator_type& a) assert(*i == *first); } +#if __cplusplus >= 201103L + +template <class T> +struct implicit_conv_allocator : min_allocator<T> +{ + implicit_conv_allocator(void* p) {} + implicit_conv_allocator(const implicit_conv_allocator&) = default; +}; + +#endif + int main() { { @@ -52,6 +63,7 @@ int main() test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc); test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc); test<std::vector<int, min_allocator<int>> >(a, an, alloc); + test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr); } #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp index c49b6686d16..19d2760227b 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp @@ -16,10 +16,27 @@ #include "../../../DefaultOnly.h" #include "../../../min_allocator.h" +#include "../../../test_allocator.h" template <class C> void -test(typename C::size_type n) +test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) +{ +#if _LIBCPP_STD_VER > 11 + C c(n, a); + assert(c.__invariants()); + assert(c.size() == n); + assert(c.get_allocator() == a); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) + assert(*i == typename C::value_type()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif +} + +template <class C> +void +test1(typename C::size_type n) { C c(n); assert(c.__invariants()); @@ -31,6 +48,14 @@ test(typename C::size_type n) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } +template <class C> +void +test(typename C::size_type n) +{ + test1<C> ( n ); + test2<C> ( n ); +} + int main() { test<std::vector<int> >(50); @@ -39,6 +64,7 @@ int main() #if __cplusplus >= 201103L test<std::vector<int, min_allocator<int>> >(50); test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500); + test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23)); assert(DefaultOnly::count == 0); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp index fe2bf1b15e6..7cca940859a 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp @@ -11,7 +11,7 @@ // template <class... Args> iterator emplace(const_iterator pos, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -107,7 +107,7 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<A> c1; std::vector<A> c2; @@ -140,7 +140,7 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<A, min_allocator<A>> c1; std::vector<A, min_allocator<A>> c2; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp index a49d59057b8..bd20844c02d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp index 0450f3df2f2..bbad13b05e3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp index 465953b4067..395d97b1ebc 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp index f0484e1c3a1..1f87c8000df 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp index 040f95f3c28..ab9cc370ee5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp index 573570d942e..141598ec477 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp index a7f8865de0a..41566a8d149 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp @@ -12,7 +12,7 @@ // template <class Iter> // iterator insert(const_iterator position, Iter first, Iter last); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -88,7 +88,7 @@ int main() for (; j < 105; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int> v(100); std::vector<int> v2(100); @@ -132,7 +132,7 @@ int main() for (; j < 105; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int, min_allocator<int>> v(100); std::vector<int, min_allocator<int>> v2(100); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp index be2289118f5..2f4b8e81ea3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, value_type&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -48,7 +48,7 @@ int main() for (++j; j < 101; ++j) assert(v[j] == MoveOnly()); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int> v1(3); std::vector<int> v2(3); @@ -69,7 +69,7 @@ int main() for (++j; j < 101; ++j) assert(v[j] == MoveOnly()); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int, min_allocator<int>> v1(3); std::vector<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp index bdfffdbbe9f..e4232ff3746 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, size_type n, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -48,7 +48,7 @@ int main() for (++j; j < 105; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int> c1(100); std::vector<int> c2; @@ -83,7 +83,7 @@ int main() for (++j; j < 105; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int, min_allocator<int>> c1(100); std::vector<int, min_allocator<int>> c2; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp index 08e18cc44d1..d24847b588e 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp @@ -11,7 +11,7 @@ // iterator insert(const_iterator position, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -46,7 +46,7 @@ int main() for (++j; j < 101; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int> v1(3); std::vector<int> v2(3); @@ -68,7 +68,7 @@ int main() for (++j; j < 101; ++j) assert(v[j] == 0); } -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::vector<int, min_allocator<int>> v1(3); std::vector<int, min_allocator<int>> v2(3); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp index f31b2339838..16891ae0026 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp @@ -11,7 +11,7 @@ // void pop_back(); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -20,7 +20,7 @@ #include "../../../stack_allocator.h" #include "../../../min_allocator.h" -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #include <cstdlib> #include <exception> @@ -34,7 +34,7 @@ int main() assert(c.size() == 1); c.pop_back(); assert(c.size() == 0); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); #endif @@ -46,7 +46,7 @@ int main() assert(c.size() == 1); c.pop_back(); assert(c.size() == 0); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp index 6454a6940d3..7443fecc4d5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp @@ -12,7 +12,7 @@ // template <class T, class Alloc> // void swap(vector<T,Alloc>& x, vector<T,Alloc>& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -23,7 +23,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket.pass.cpp index 2f7cac6c535..aa69708e319 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket(const key_type& __k) const; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket_size.pass.cpp index 3d2802a5f8a..6000ab920e3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/bucket_size.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket_size(size_type n) const -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_7.pass.cpp index 11c5349103c..4e1ad1e045b 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_8.pass.cpp index be9dbb6e29d..dbf0ddeb755 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp index aa83fae4d7b..95797f2484e 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment local_iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp index cfb2432687f..8a2ae7641d7 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/max_load_factor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/max_load_factor.pass.cpp index 261078b5856..925997bd752 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/max_load_factor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/max_load_factor.pass.cpp @@ -16,7 +16,7 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp index 0f9e4cefb59..b49d6bfe994 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp @@ -65,5 +65,47 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_allocator<std::pair<const T, T>> A; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef std::unordered_map<T, T, HF, Comp, A> C; + + A a(10); + C c(2, a); + assert(c.bucket_count() == 2); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_allocator<std::pair<const T, T>> A; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef std::unordered_map<T, T, HF, Comp, A> C; + + A a(10); + HF hf(12); + C c(2, hf, a); + assert(c.bucket_count() == 2); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp index f94353f8a91..f722249b6f6 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp @@ -213,7 +213,7 @@ int main() assert(c0.size() == 0); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}}; std::unordered_map<int, int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp index be5a70fcbf5..594331c3d0d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp @@ -91,6 +91,72 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_map<int, std::string, HF, Comp, A> C; + + A a(42); + C c ( { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash<std::hash<int> >()); + assert(c.key_eq() == test_compare<std::equal_to<int> >()); + assert(c.get_allocator() == a); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_map<int, std::string, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c ( { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, 12, hf, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == test_hash<std::hash<int> >())); + assert(c.key_eq() == test_compare<std::equal_to<int> >()); + assert(c.get_allocator() == a); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp index 9460dd36502..41055c40e22 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp @@ -184,7 +184,7 @@ int main() assert(c0.empty()); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}}; std::unordered_map<int, int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp index 25e1d8d641d..bc316d325a5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp @@ -97,5 +97,74 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_map<int, std::string, HF, Comp, A> C; + + P arr[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14); + assert(c.bucket_count() >= 14); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_map<int, std::string, HF, Comp, A> C; + + P arr[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + HF hf(42); + A a(43); + C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a); + assert(c.bucket_count() >= 14); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp index 9821412e6e2..6ab9c923da3 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp @@ -15,7 +15,7 @@ // void swap(unordered_map& x, unordered_map& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -24,7 +24,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::pair<int, int> P; P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)}; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp index 1d6d632110e..7cd14c63047 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp @@ -16,7 +16,7 @@ // template <class... Args> // iterator emplace_hint(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -76,7 +76,7 @@ int main() assert(r->second == Emplaceable(6, 7)); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_map<int, Emplaceable> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp index 2106484be72..60b093553f1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp index 588539bcdd2..05046f5dedc 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp index 3fd4006847a..81a8d3de157 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp index e1e38dfd5eb..4b103a0ad75 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp index e9a96f1bcac..6ef1e07add1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp index 76c5858323c..1185ddf8fd4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp index 4071950fdad..2e4230af16d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -81,7 +81,7 @@ int main() assert(r->second == 4); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_map<double, int> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp index 97e39ed31e5..5a4fd23aaf0 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp @@ -17,7 +17,7 @@ // class = typename enable_if<is_convertible<P, value_type>::value>::type> // iterator insert(const_iterator p, P&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -140,7 +140,7 @@ int main() assert(r->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_map<double, int> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket.pass.cpp index 230b6aae976..46f7334027b 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket(const key_type& __k) const; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket_size.pass.cpp index 27ae7069ca4..1528a347b60 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/bucket_size.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket_size(size_type n) const -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp index 92cf1f50a87..e7f06fe4d2c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp index b1fb3389c84..2f7a0d91ebc 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp index 5237e17ebb5..330374f576c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment local_iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp index a6f7db47bae..9185147404c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/max_load_factor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/max_load_factor.pass.cpp index 8a1daf5bd9b..0a208452dd6 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/max_load_factor.pass.cpp @@ -16,7 +16,7 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/scary.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/scary.pass.cpp new file mode 100644 index 00000000000..e619a7a5429 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/scary.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// class unordered_map class unordered_multimap + +// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap + +#include <unordered_map> + +int main() +{ + typedef std::unordered_map<int, int> M1; + typedef std::unordered_multimap<int, int> M2; + M2::iterator i; + M1::iterator j = i; +} diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp index 1f7f4034057..dbcdca44a6e 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp @@ -65,5 +65,47 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_allocator<std::pair<const T, T>> A; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef std::unordered_multimap<T, T, HF, Comp, A> C; + + A a(10); + C c(2, a); + assert(c.bucket_count() == 2); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_allocator<std::pair<const T, T>> A; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef std::unordered_multimap<T, T, HF, Comp, A> C; + + A a(10); + HF hf(12); + C c(2, hf, a); + assert(c.bucket_count() == 2); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp index 99d99e6334e..8c7bc76ec24 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp @@ -290,7 +290,7 @@ int main() assert(c.max_load_factor() == 1); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}}; std::unordered_multimap<int, int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp index b4b2ac58f1c..bcde6666eb2 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp @@ -135,6 +135,120 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >())); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_multimap<int, std::string, HF, Comp, A> C; + + A a(42); + C c ({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, 12, a ); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + typedef std::pair<C::const_iterator, C::const_iterator> Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + } + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_multimap<int, std::string, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c ({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, 12, hf, a ); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + typedef std::pair<C::const_iterator, C::const_iterator> Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp index 997d31907b2..b4983eaf3d5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp @@ -228,7 +228,7 @@ int main() assert(c0.empty()); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}}; std::unordered_multimap<int, int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp index 74171c71f70..a4314813111 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp @@ -141,5 +141,123 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >())); } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_multimap<int, std::string, HF, Comp, A> C; + + P arr[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + A a(42); + C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, a); + assert(c.bucket_count() >= 14); + assert(c.size() == 6); + typedef std::pair<C::const_iterator, C::const_iterator> Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + } + { + typedef std::pair<int, std::string> P; + typedef test_allocator<std::pair<const int, std::string>> A; + typedef test_hash<std::hash<int>> HF; + typedef test_compare<std::equal_to<int>> Comp; + typedef std::unordered_multimap<int, std::string, HF, Comp, A> C; + + P arr[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + A a(42); + HF hf (43); + C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a ); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + typedef std::pair<C::const_iterator, C::const_iterator> Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp index 5323d67fedb..13776deea55 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp @@ -16,7 +16,7 @@ // template <class... Args> // iterator emplace_hint(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -92,7 +92,7 @@ int main() assert(r->second == Emplaceable(5, 6)); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multimap<int, Emplaceable> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp index 248b93f0c4e..83ccf3b7396 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp index e966986692d..fffcfa69142 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp index 87240d2ba5a..be6caba5902 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp index fe88b392f78..a6d54084e72 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp index 7130b8b59e5..301cfb4402d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp index a9433de5516..b53b486a56a 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp index 0d77660495a..f7149a5a403 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -81,7 +81,7 @@ int main() assert(r->second == 4); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multimap<double, int> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp index fc0919d3782..0489fc71e89 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp @@ -17,7 +17,7 @@ // class = typename enable_if<is_convertible<P, value_type>::value>::type> // iterator insert(const_iterator p, P&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -140,7 +140,7 @@ int main() assert(r->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multimap<double, int> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp index 311f9c10cfd..a332b6fa418 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp @@ -15,7 +15,7 @@ // void swap(unordered_multimap& x, unordered_multimap& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -24,7 +24,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::pair<int, int> P; P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)}; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket.pass.cpp index e75a133f361..2d8927d6710 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket(const key_type& __k) const; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket_size.pass.cpp index 3e710870640..8718223fbc9 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/bucket_size.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket_size(size_type n) const -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp index f6ed6c77674..92611ca767c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp index 289fa5e2816..635e2115d88 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp index b2f4017dd58..8bfe0fcd01f 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment local_iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp index 47afad41167..1adc686b81d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/emplace_hint.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/emplace_hint.pass.cpp index e15316999be..eddffc40df2 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/emplace_hint.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/emplace_hint.pass.cpp @@ -16,7 +16,7 @@ // template <class... Args> // iterator emplace_hint(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -66,7 +66,7 @@ int main() assert(*r == Emplaceable(5, 6)); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multiset<Emplaceable> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp index beab0bb02fd..baad3858bd4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp index a58e79a0fe2..a21f29ef7b4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp index de8bca8b081..03c9ec5d048 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp index 8abded2a65e..4c6f209f1a4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp index 626def41db6..5ce378974c9 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp index 4840234a819..7c362a2a2b1 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp index c27b5c2fe2e..d3a3d767218 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -73,7 +73,7 @@ int main() assert(*r == 5.5); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multiset<double> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp index 23ac2316c41..fb95ea32f3d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, value_type&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -122,7 +122,7 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multiset<double> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/max_load_factor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/max_load_factor.pass.cpp index 72413be1eb0..00cd1b1f3a9 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/max_load_factor.pass.cpp @@ -16,7 +16,7 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/scary.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/scary.pass.cpp new file mode 100644 index 00000000000..dfd144bb317 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/scary.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// class unordered_set class unordered_multiset + +// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset + +#include <unordered_set> + +int main() +{ + typedef std::unordered_set<int> M1; + typedef std::unordered_multiset<int> M2; + M2::iterator i; + M1::iterator j = i; +} diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp index db8ba0e79bd..af9dd01bf32 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp index c77846aa8b8..942ab86ae64 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp @@ -270,7 +270,7 @@ int main() assert(c.max_load_factor() == 1); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_multiset<int> s1 = {1, 2, 3}; std::unordered_multiset<int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp index 29729b5a4b0..3578d35e534 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp index 92c578109f0..593ba0dae5c 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp @@ -179,7 +179,7 @@ int main() assert(c0.empty()); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_multiset<int> s1 = {1, 2, 3}; std::unordered_multiset<int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp index 8c0828ae417..1286eeef1ce 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp @@ -93,5 +93,75 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp index d75d227d90c..9470b1a6fa8 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp @@ -15,7 +15,7 @@ // void swap(unordered_multiset& x, unordered_multiset& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -24,7 +24,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket.pass.cpp index a07ef25931f..b2bf2e1cd59 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket(const key_type& __k) const; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket_size.pass.cpp index 13b8257fe0e..26f05dbd3d8 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/bucket_size.pass.cpp @@ -15,7 +15,7 @@ // size_type bucket_size(size_type n) const -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_7.pass.cpp index 978ee088399..3247f01a391 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_8.pass.cpp index 26411871fe2..4ee888335c7 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp index 87fdf1b2d7b..e6df2a471d5 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp @@ -11,7 +11,7 @@ // Increment local_iterator past end. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp index 33d7be053bf..0c5a1677b44 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp @@ -11,7 +11,7 @@ // Dereference non-dereferenceable iterator. -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/emplace_hint.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/emplace_hint.pass.cpp index b988669c962..0d8a57aa995 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/emplace_hint.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/emplace_hint.pass.cpp @@ -16,7 +16,7 @@ // template <class... Args> // iterator emplace_hint(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -66,7 +66,7 @@ int main() assert(*r == Emplaceable(5, 6)); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_set<Emplaceable> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db1.pass.cpp index 4cecf26df50..231152d14f4 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with end() -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db2.pass.cpp index 0f6a102ecb5..06d61db017d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator position) with iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp index ce0eb0bbc45..92c77f5567d 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with first iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp index 6b06bb4194c..d6066589624 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with second iterator from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp index 33902f10003..f7ff42621fe 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with both iterators from another container -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp index 79fc846c044..6cde216f4a9 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp @@ -11,7 +11,7 @@ // Call erase(const_iterator first, const_iterator last); with a bad range -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp index 46c32fa2e92..c195e522ddf 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, const value_type& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -73,7 +73,7 @@ int main() assert(*r == 5.5); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_set<double> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp index e5ba2c0a489..ff7d742bb62 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp @@ -15,7 +15,7 @@ // iterator insert(const_iterator p, value_type&& x); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -122,7 +122,7 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { typedef std::unordered_set<double> C; typedef C::iterator R; diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/max_load_factor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/max_load_factor.pass.cpp index 44cf865d2d1..982c6b578c9 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/max_load_factor.pass.cpp @@ -16,7 +16,7 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp index 31878362f1e..5d7897b90f7 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp index 02e1b976720..a197fca8376 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp @@ -209,7 +209,7 @@ int main() assert(c.max_load_factor() == 1); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_set<int> s1 = {1, 2, 3}; std::unordered_set<int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp index 8dc37e30465..fcee4007ee0 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp index 4967679e89f..3f1685c7975 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp @@ -179,7 +179,7 @@ int main() assert(c0.empty()); } #endif -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { std::unordered_set<int> s1 = {1, 2, 3}; std::unordered_set<int>::iterator i = s1.begin(); diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp index 322fa3ff5a3..d0166fab893 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp @@ -93,5 +93,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + +#endif #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp index 829fc95be87..2e8250ef783 100644 --- a/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp @@ -15,7 +15,7 @@ // void swap(unordered_set& x, unordered_set& y); -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) #endif @@ -24,7 +24,7 @@ int main() { -#if _LIBCPP_DEBUG2 >= 1 +#if _LIBCPP_DEBUG >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/external/bsd/libc++/dist/libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp new file mode 100644 index 00000000000..0573ef862ef --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_category + +// constexpr error_category() noexcept; + +#include <system_error> +#include <type_traits> +#include <string> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class test1 + : public std::error_category +{ +public: + constexpr test1() = default; // won't compile if error_category() is not constexpr + virtual const char* name() const noexcept {return nullptr;} + virtual std::string message(int ev) const {return std::string();} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_nothrow_default_constructible<test1>::value, + "error_category() must exist and be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp index 9b2e5118fff..1a60dd6b473 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp @@ -118,7 +118,9 @@ int main() static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), ""); static_assert((std::is_same<decltype(std::getc(fp)), int>::value), ""); static_assert((std::is_same<decltype(std::getchar()), int>::value), ""); +#if _LIBCPP_STD_VER <= 11 static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), ""); +#endif static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), ""); static_assert((std::is_same<decltype(std::putchar(0)), int>::value), ""); static_assert((std::is_same<decltype(std::puts("")), int>::value), ""); diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/gets.fail.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/gets.fail.cpp new file mode 100644 index 00000000000..4250e23c11c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/input.output/file.streams/c.files/gets.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// test <cstdio> + +// gets + +#include <cstdio> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + (void) std::gets((char *) NULL); +#else +#error +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp index 1309a00df57..3d4df9cbb7f 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <istream> diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp index ee46566c935..d060ccce47a 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <istream> diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp index b57014a9f28..636cf078d74 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <istream> diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp index 005b3b48446..73f3da1c6bd 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp @@ -57,12 +57,18 @@ int main() is.seekg(5, std::ios_base::cur); assert(is.good()); assert(seekoff_called == 1); + is.seekg(-1, std::ios_base::beg); + assert(is.fail()); + assert(seekoff_called == 2); } { testbuf<wchar_t> sb(L" 123456789"); std::wistream is(&sb); is.seekg(5, std::ios_base::cur); assert(is.good()); - assert(seekoff_called == 2); + assert(seekoff_called == 3); + is.seekg(-1, std::ios_base::beg); + assert(is.fail()); + assert(seekoff_called == 4); } } diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp index 16fbf656076..69b26f3a96e 100644 --- a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp @@ -54,6 +54,6 @@ int main() assert(os.good()); assert(&os.seekp(-1, std::ios_base::beg) == &os); assert(seekoff_called == 2); - assert(os.good()); + assert(os.fail()); } } diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp new file mode 100644 index 00000000000..9f2d7c8ecce --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp @@ -0,0 +1,192 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// quoted + +#include <iomanip> +#include <sstream> +#include <string> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +bool is_skipws ( const std::istream *is ) { + return ( is->flags() & std::ios_base::skipws ) != 0; + } + + +bool is_skipws ( const std::wistream *is ) { + return ( is->flags() & std::ios_base::skipws ) != 0; + } + +void round_trip ( const char *p ) { + std::stringstream ss; + bool skippingws = is_skipws ( &ss ); + ss << std::quoted(p); + std::string s; + ss >> std::quoted(s); + assert ( s == p ); + assert ( skippingws == is_skipws ( &ss )); + } + +void round_trip_ws ( const char *p ) { + std::stringstream ss; + std::noskipws ( ss ); + bool skippingws = is_skipws ( &ss ); + ss << std::quoted(p); + std::string s; + ss >> std::quoted(s); + assert ( s == p ); + assert ( skippingws == is_skipws ( &ss )); + } + +void round_trip_d ( const char *p, char delim ) { + std::stringstream ss; + ss << std::quoted(p, delim); + std::string s; + ss >> std::quoted(s, delim); + assert ( s == p ); + } + +void round_trip_e ( const char *p, char escape ) { + std::stringstream ss; + ss << std::quoted(p, '"', escape ); + std::string s; + ss >> std::quoted(s, '"', escape ); + assert ( s == p ); + } + + + +std::string quote ( const char *p, char delim='"', char escape='\\' ) { + std::stringstream ss; + ss << std::quoted(p, delim, escape); + std::string s; + ss >> s; // no quote + return s; +} + +std::string unquote ( const char *p, char delim='"', char escape='\\' ) { + std::stringstream ss; + ss << p; + std::string s; + ss >> std::quoted(s, delim, escape); + return s; +} + + +void round_trip ( const wchar_t *p ) { + std::wstringstream ss; + bool skippingws = is_skipws ( &ss ); + ss << std::quoted(p); + std::wstring s; + ss >> std::quoted(s); + assert ( s == p ); + assert ( skippingws == is_skipws ( &ss )); + } + + +void round_trip_ws ( const wchar_t *p ) { + std::wstringstream ss; + std::noskipws ( ss ); + bool skippingws = is_skipws ( &ss ); + ss << std::quoted(p); + std::wstring s; + ss >> std::quoted(s); + assert ( s == p ); + assert ( skippingws == is_skipws ( &ss )); + } + +void round_trip_d ( const wchar_t *p, wchar_t delim ) { + std::wstringstream ss; + ss << std::quoted(p, delim); + std::wstring s; + ss >> std::quoted(s, delim); + assert ( s == p ); + } + +void round_trip_e ( const wchar_t *p, wchar_t escape ) { + std::wstringstream ss; + ss << std::quoted(p, wchar_t('"'), escape ); + std::wstring s; + ss >> std::quoted(s, wchar_t('"'), escape ); + assert ( s == p ); + } + + +std::wstring quote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) { + std::wstringstream ss; + ss << std::quoted(p, delim, escape); + std::wstring s; + ss >> s; // no quote + return s; +} + +std::wstring unquote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) { + std::wstringstream ss; + ss << p; + std::wstring s; + ss >> std::quoted(s, delim, escape); + return s; +} + +int main() +{ + round_trip ( "" ); + round_trip_ws ( "" ); + round_trip_d ( "", 'q' ); + round_trip_e ( "", 'q' ); + + round_trip ( L"" ); + round_trip_ws ( L"" ); + round_trip_d ( L"", 'q' ); + round_trip_e ( L"", 'q' ); + + round_trip ( "Hi" ); + round_trip_ws ( "Hi" ); + round_trip_d ( "Hi", '!' ); + round_trip_e ( "Hi", '!' ); + assert ( quote ( "Hi", '!' ) == "!Hi!" ); + assert ( quote ( "Hi!", '!' ) == R"(!Hi\!!)" ); + + round_trip ( L"Hi" ); + round_trip_ws ( L"Hi" ); + round_trip_d ( L"Hi", '!' ); + round_trip_e ( L"Hi", '!' ); + assert ( quote ( L"Hi", '!' ) == L"!Hi!" ); + assert ( quote ( L"Hi!", '!' ) == LR"(!Hi\!!)" ); + + round_trip ( "Hi Mom" ); + round_trip_ws ( "Hi Mom" ); + round_trip ( L"Hi Mom" ); + round_trip_ws ( L"Hi Mom" ); + + assert ( quote ( "" ) == "\"\"" ); + assert ( quote ( L"" ) == L"\"\"" ); + assert ( quote ( "a" ) == "\"a\"" ); + assert ( quote ( L"a" ) == L"\"a\"" ); + +// missing end quote - must not hang + assert ( unquote ( "\"abc" ) == "abc" ); + assert ( unquote ( L"\"abc" ) == L"abc" ); + + assert ( unquote ( "abc" ) == "abc" ); // no delimiter + assert ( unquote ( L"abc" ) == L"abc" ); // no delimiter + assert ( unquote ( "abc def" ) == "abc" ); // no delimiter + assert ( unquote ( L"abc def" ) == L"abc" ); // no delimiter + + assert ( unquote ( "" ) == "" ); // nothing there + assert ( unquote ( L"" ) == L"" ); // nothing there + } + +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp new file mode 100644 index 00000000000..2f516f8fbc9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// quoted + +#include <iomanip> +#include <sstream> +#include <string> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +void round_trip ( const char *p ) { + std::wstringstream ss; + ss << std::quoted(p); + std::string s; + ss >> std::quoted(s); + } + + + +int main() +{ + round_trip ( "Hi Mom" ); +} +#else +#error +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp new file mode 100644 index 00000000000..bdd362df19c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// quoted + +#include <iomanip> +#include <sstream> +#include <string> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +template <class charT> +struct test_traits +{ + typedef charT char_type; +}; + +void round_trip ( const char *p ) { + std::stringstream ss; + ss << std::quoted(p); + std::basic_string<char, test_traits<char>> s; + ss >> std::quoted(s); + } + + + +int main() +{ + round_trip ( "Hi Mom" ); +} +#else +#error +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/iterators/iterator.range/begin-end.pass.cpp b/external/bsd/libc++/dist/libcxx/test/iterators/iterator.range/begin-end.pass.cpp new file mode 100644 index 00000000000..e8a6c18fd49 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/iterators/iterator.range/begin-end.pass.cpp @@ -0,0 +1,125 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> +// template <class C> auto begin(C& c) -> decltype(c.begin()); +// template <class C> auto begin(const C& c) -> decltype(c.begin()); +// template <class C> auto end(C& c) -> decltype(c.end()); +// template <class C> auto end(const C& c) -> decltype(c.end()); +// template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); +// template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); + +#include <__config> + +#if __cplusplus >= 201103L +#include <iterator> +#include <cassert> +#include <vector> +#include <array> +#include <list> +#include <initializer_list> + +template<typename C> +void test_const_container( const C & c, typename C::value_type val ) { + assert ( std::begin(c) == c.begin()); + assert (*std::begin(c) == val ); + assert ( std::begin(c) != c.end()); + assert ( std::end(c) == c.end()); +#if _LIBCPP_STD_VER > 11 + assert ( std::cbegin(c) == c.cbegin()); + assert ( std::cbegin(c) != c.cend()); + assert ( std::cend(c) == c.cend()); + assert ( std::rbegin(c) == c.rbegin()); + assert ( std::rbegin(c) != c.rend()); + assert ( std::rend(c) == c.rend()); + assert ( std::crbegin(c) == c.crbegin()); + assert ( std::crbegin(c) != c.crend()); + assert ( std::crend(c) == c.crend()); +#endif + } + +template<typename T> +void test_const_container( const std::initializer_list<T> & c, T val ) { + assert ( std::begin(c) == c.begin()); + assert (*std::begin(c) == val ); + assert ( std::begin(c) != c.end()); + assert ( std::end(c) == c.end()); +#if _LIBCPP_STD_VER > 11 +// initializer_list doesn't have cbegin/cend/rbegin/rend +// assert ( std::cbegin(c) == c.cbegin()); +// assert ( std::cbegin(c) != c.cend()); +// assert ( std::cend(c) == c.cend()); +// assert ( std::rbegin(c) == c.rbegin()); +// assert ( std::rbegin(c) != c.rend()); +// assert ( std::rend(c) == c.rend()); +// assert ( std::crbegin(c) == c.crbegin()); +// assert ( std::crbegin(c) != c.crend()); +// assert ( std::crend(c) == c.crend()); +#endif + } + +template<typename C> +void test_container( C & c, typename C::value_type val ) { + assert ( std::begin(c) == c.begin()); + assert (*std::begin(c) == val ); + assert ( std::begin(c) != c.end()); + assert ( std::end(c) == c.end()); +#if _LIBCPP_STD_VER > 11 + assert ( std::cbegin(c) == c.cbegin()); + assert ( std::cbegin(c) != c.cend()); + assert ( std::cend(c) == c.cend()); + assert ( std::rbegin(c) == c.rbegin()); + assert ( std::rbegin(c) != c.rend()); + assert ( std::rend(c) == c.rend()); + assert ( std::crbegin(c) == c.crbegin()); + assert ( std::crbegin(c) != c.crend()); + assert ( std::crend(c) == c.crend()); +#endif + } + +template<typename T> +void test_container( std::initializer_list<T> & c, T val ) { + assert ( std::begin(c) == c.begin()); + assert (*std::begin(c) == val ); + assert ( std::begin(c) != c.end()); + assert ( std::end(c) == c.end()); +#if _LIBCPP_STD_VER > 11 +// initializer_list doesn't have cbegin/cend/rbegin/rend +// assert ( std::cbegin(c) == c.cbegin()); +// assert ( std::cbegin(c) != c.cend()); +// assert ( std::cend(c) == c.cend()); +// assert ( std::rbegin(c) == c.rbegin()); +// assert ( std::rbegin(c) != c.rend()); +// assert ( std::rend(c) == c.rend()); +// assert ( std::crbegin(c) == c.crbegin()); +// assert ( std::crbegin(c) != c.crend()); +// assert ( std::crend(c) == c.crend()); +#endif + } + +int main(){ + std::vector<int> v; v.push_back(1); + std::list<int> l; l.push_back(2); + std::array<int, 1> a; a[0] = 3; + std::initializer_list<int> il = { 4 }; + + test_container ( v, 1 ); + test_container ( l, 2 ); + test_container ( a, 3 ); + test_container ( il, 4 ); + + test_const_container ( v, 1 ); + test_const_container ( l, 2 ); + test_const_container ( a, 3 ); + test_const_container ( il, 4 ); +} + +#else +int main(){} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp b/external/bsd/libc++/dist/libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp index 19535c760de..06834981ef3 100644 --- a/external/bsd/libc++/dist/libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp @@ -30,10 +30,17 @@ test(It i) int main() { + { char s[] = "1234567890"; test(input_iterator<char*>(s+5)); test(forward_iterator<char*>(s+5)); test(bidirectional_iterator<char*>(s+5)); test(random_access_iterator<char*>(s+5)); test(s+5); + } + { + int a[] = {1,2,3,4}; + std::make_move_iterator(a+4); + std::make_move_iterator(a); // test for LWG issue 2061 + } } diff --git a/external/bsd/libc++/dist/libcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp b/external/bsd/libc++/dist/libcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp new file mode 100644 index 00000000000..7de50330455 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test bad_array_length + +#include <new> +#include <type_traits> +#include <cassert> + +int main() +{ +#if __LIBCPP_STD_VER > 11 + static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value), + "std::is_base_of<std::bad_alloc, std::bad_array_length>::value"); + static_assert(std::is_polymorphic<std::bad_array_length>::value, + "std::is_polymorphic<std::bad_array_length>::value"); + std::bad_array_length b; + std::bad_array_length b2 = b; + b2 = b; + const char* w = b2.what(); + assert(w); +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.access/access.pass.cpp b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.access/access.pass.cpp index 1d6d6e28868..2f0720639c6 100644 --- a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.access/access.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.access/access.pass.cpp @@ -32,6 +32,23 @@ struct A } }; +#if _LIBCPP_STD_VER > 11 +struct B +{ + constexpr B(std::initializer_list<int> il) + { + const int* b = il.begin(); + const int* e = il.end(); + assert(il.size() == 3); + assert(e - b == il.size()); + assert(*b++ == 3); + assert(*b++ == 2); + assert(*b++ == 1); + } +}; + +#endif // _LIBCPP_STD_VER > 11 + #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int main() @@ -39,4 +56,7 @@ int main() #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS A test1 = {3, 2, 1}; #endif +#if _LIBCPP_STD_VER > 11 + constexpr B test2 = {3, 2, 1}; +#endif // _LIBCPP_STD_VER > 11 } diff --git a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp index 1cb52f41373..7822a62206a 100644 --- a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp @@ -22,4 +22,8 @@ int main() std::initializer_list<A> il; assert(il.size() == 0); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + constexpr std::initializer_list<A> il2; + static_assert(il2.size() == 0, ""); +#endif // _LIBCPP_STD_VER > 11 } diff --git a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp index 2c30d9abc24..5fcd28f9156 100644 --- a/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp @@ -30,6 +30,22 @@ struct A } }; +#if _LIBCPP_STD_VER > 11 +struct B +{ + constexpr B(std::initializer_list<int> il) + { + const int* b = begin(il); + const int* e = end(il); + assert(il.size() == 3); + assert(e - b == il.size()); + assert(*b++ == 3); + assert(*b++ == 2); + assert(*b++ == 1); + } +}; + +#endif // _LIBCPP_STD_VER > 11 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int main() @@ -37,4 +53,7 @@ int main() #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS A test1 = {3, 2, 1}; #endif +#if _LIBCPP_STD_VER > 11 + constexpr B test2 = {3, 2, 1}; +#endif // _LIBCPP_STD_VER > 11 } diff --git a/external/bsd/libc++/dist/libcxx/test/lit.cfg b/external/bsd/libc++/dist/libcxx/test/lit.cfg index f6add156f21..aa454397467 100644 --- a/external/bsd/libc++/dist/libcxx/test/lit.cfg +++ b/external/bsd/libc++/dist/libcxx/test/lit.cfg @@ -2,41 +2,21 @@ # Configuration file for the 'lit' test runner. +import errno import os -import sys import platform -import tempfile +import re +import shlex import signal import subprocess -import errno +import sys +import tempfile import time -import shlex import lit.Test import lit.formats import lit.util -# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a -# dependency there. What we more ideally would like to do is lift the "xfail" -# and "requires" handling to be a core lit framework feature. -def isExpectedFail(test, xfails): - # Check if any of the xfails match an available feature or the target. - for item in xfails: - # If this is the wildcard, it always fails. - if item == '*': - return True - - # If this is a part of any of the features, it fails. - for feature in test.config.available_features: - if item in feature: - return True - - # If this is a part of the target triple, it fails. - if item in test.suite.config.target_triple: - return True - - return False - class LibcxxTestFormat(lit.formats.FileBasedTest): """ Custom test format handler for use with the test format use by libc++. @@ -82,13 +62,12 @@ class LibcxxTestFormat(lit.formats.FileBasedTest): def _execute(self, test, lit_config): # Extract test metadata from the test file. - xfails = [] requires = [] with open(test.getSourcePath()) as f: for ln in f: if 'XFAIL:' in ln: items = ln[ln.index('XFAIL:') + 6:].split(',') - xfails.extend([s.strip() for s in items]) + test.xfails.extend([s.strip() for s in items]) elif 'REQUIRES:' in ln: items = ln[ln.index('REQUIRES:') + 9:].split(',') requires.extend([s.strip() for s in items]) @@ -101,8 +80,7 @@ class LibcxxTestFormat(lit.formats.FileBasedTest): # # FIXME: For now, this is cribbed from lit.TestRunner, to avoid # introducing a dependency there. What we more ideally would like to do - # is lift the "xfail" and "requires" handling to be a core lit - # framework feature. + # is lift the "requires" handling to be a core lit framework feature. missing_required_features = [f for f in requires if f not in test.config.available_features] if missing_required_features: @@ -110,21 +88,8 @@ class LibcxxTestFormat(lit.formats.FileBasedTest): "Test requires the following features: %s" % ( ', '.join(missing_required_features),)) - # Determine if this test is an expected failure. - isXFail = isExpectedFail(test, xfails) - # Evaluate the test. - result, report = self._evaluate_test(test, lit_config) - - # Convert the test result based on whether this is an expected failure. - if isXFail: - if result != lit.Test.FAIL: - report += "\n\nTest was expected to FAIL, but did not.\n" - result = lit.Test.XPASS - else: - result = lit.Test.XFAIL - - return result, report + return self._evaluate_test(test, lit_config) def _evaluate_test(self, test, lit_config): name = test.path_in_suite[-1] @@ -269,14 +234,27 @@ link_flags_str = lit_config.params.get('link_flags', None) if link_flags_str is None: link_flags_str = getattr(config, 'link_flags', None) if link_flags_str is None: - if sys.platform == 'darwin': - link_flags += ['-lSystem'] - elif sys.platform == 'linux2': - link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', - '-lrt', '-lgcc_s'] - else: - lit_config.fatal("unrecognized system") - lit_config.note("inferred link_flags as: %r" % (link_flags,)) + cxx_abi = getattr(config, 'cxx_abi', 'libcxxabi') + if cxx_abi == 'libstdc++': + link_flags += ['-lstdc++'] + elif cxx_abi == 'libsupc++': + link_flags += ['-lsupc++'] + elif cxx_abi == 'libcxxabi': + link_flags += ['-lc++abi'] + elif cxx_abi == 'none': + pass + else: + lit_config.fatal('C++ ABI setting %s unsupported for tests' % cxx_abi) + + if sys.platform == 'darwin': + link_flags += ['-lSystem'] + elif sys.platform == 'linux2': + link_flags += [ '-lgcc_eh', '-lc', '-lm', '-lpthread', + '-lrt', '-lgcc_s'] + else: + lit_config.fatal("unrecognized system") + + lit_config.note("inferred link_flags as: %r" % (link_flags,)) if not link_flags_str is None: link_flags += shlex.split(link_flags_str) @@ -320,5 +298,8 @@ if config.target_triple is None: # known to fail with versions of libc++ as were shipped with a particular # triple. if use_system_lib: - config.available_features.add('with_system_lib=%s' % ( - config.target_triple,)) + # Drop sub-major version components from the triple, because the current + # XFAIL handling expects exact matches for feature checks. + sanitized_triple = re.sub(r"([^-]+)-([^-]+)-([^-.]+).*", r"\1-\2-\3", + config.target_triple) + config.available_features.add('with_system_lib=%s' % (sanitized_triple,)) diff --git a/external/bsd/libc++/dist/libcxx/test/lit.site.cfg.in b/external/bsd/libc++/dist/libcxx/test/lit.site.cfg.in index 61406bf47ad..5343eda540b 100644 --- a/external/bsd/libc++/dist/libcxx/test/lit.site.cfg.in +++ b/external/bsd/libc++/dist/libcxx/test/lit.site.cfg.in @@ -5,6 +5,7 @@ config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@" config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.enable_shared = @LIBCXX_ENABLE_SHARED@ +config.cxx_abi = "@LIBCXX_CXX_ABI@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg") diff --git a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp index c99953253c1..6935c3e8405 100644 --- a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp @@ -37,6 +37,10 @@ void operator delete(void* p) throw() int main() { typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible<std::streambuf*, B>::value, ""); + static_assert( std::is_constructible<B, std::streambuf*>::value, ""); +#endif { B b; assert(b.rdbuf() == nullptr); diff --git a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp index 887d1f0538e..9099b5e38fc 100644 --- a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp @@ -30,5 +30,9 @@ int main() typedef std::wstring_convert<Codecvt> Myconv; Myconv myconv(new Codecvt); assert(myconv.converted() == 0); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible<Codecvt*, Myconv>::value, ""); + static_assert( std::is_constructible<Myconv, Codecvt*>::value, ""); +#endif } } diff --git a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp index 62f68575ec2..27a3da76270 100644 --- a/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp @@ -22,6 +22,10 @@ int main() { typedef std::codecvt_utf8<wchar_t> Codecvt; typedef std::wstring_convert<Codecvt> Myconv; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible<std::string, Myconv>::value, ""); + static_assert( std::is_constructible<Myconv, std::string>::value, ""); +#endif { Myconv myconv; try diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals.pass.cpp new file mode 100644 index 00000000000..45b59914e7f --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +#include <complex> +#include <type_traits> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals::complex_literals; + +// Make sure the types are right + static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" ); + static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" ); + static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" ); + static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" ); + static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" ); + static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" ); + + { + std::complex<long double> c1 = 3.0il; + assert ( c1 == std::complex<long double>(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex<double> c1 = 3.0i; + assert ( c1 == std::complex<double>(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex<float> c1 = 3.0if; + assert ( c1 == std::complex<float>(0, 3.0)); + auto c2 = 3if; + assert ( c1 == c2 ); + } + +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.fail.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.fail.cpp new file mode 100644 index 00000000000..0f31d595566 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.fail.cpp @@ -0,0 +1,20 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#include <complex> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::complex<float> foo = 1.0if; // should fail w/conversion operator not found +#else +#error +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.pass.cpp new file mode 100644 index 00000000000..46903bbd565 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals1.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +#include <complex> +#include <type_traits> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals; + + { + std::complex<long double> c1 = 3.0il; + assert ( c1 == std::complex<long double>(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex<double> c1 = 3.0i; + assert ( c1 == std::complex<double>(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex<float> c1 = 3.0if; + assert ( c1 == std::complex<float>(0, 3.0)); + auto c2 = 3if; + assert ( c1 == c2 ); + } + +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals2.pass.cpp new file mode 100644 index 00000000000..8bd8acd981b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.literals/literals2.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +#include <complex> +#include <type_traits> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std; + + { + std::complex<long double> c1 = 3.0il; + assert ( c1 == std::complex<long double>(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex<double> c1 = 3.0i; + assert ( c1 == std::complex<double>(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex<float> c1 = 3.0if; + assert ( c1 == std::complex<float>(0, 3.0)); + auto c2 = 3if; + assert ( c1 == c2 ); + } + +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.ops/stream_input.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.ops/stream_input.pass.cpp index 1876147afc3..107eefc0134 100644 --- a/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.ops/stream_input.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/numerics/complex.number/complex.ops/stream_input.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <complex> diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp index 623371edc97..46741e1e41b 100644 --- a/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp @@ -38,6 +38,43 @@ test() assert(ib[i] == ir[i]); } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +class Y; + +class X +{ + int i_; + + X& operator=(const X&); +public: + explicit X(int i) : i_(i) {} + X(const X& x) : i_(x.i_) {} + X& operator=(X&& x) + { + i_ = x.i_; + x.i_ = -1; + return *this; + } + + friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);} + + friend class Y; +}; + +class Y +{ + int i_; + + Y& operator=(const Y&); +public: + explicit Y(int i) : i_(i) {} + Y(const Y& y) : i_(y.i_) {} + void operator=(const X& x) {i_ = x.i_;} +}; + +#endif + int main() { test<input_iterator<const int*>, output_iterator<int*> >(); @@ -69,4 +106,10 @@ int main() test<const int*, bidirectional_iterator<int*> >(); test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + X x[3] = {X(1), X(2), X(3)}; + Y y[3] = {Y(1), Y(2), Y(3)}; + std::adjacent_difference(x, x+3, y); +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp index a8fbfbe00f6..fb0bbdc2836 100644 --- a/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp @@ -40,6 +40,44 @@ test() assert(ib[i] == ir[i]); } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +class Y; + +class X +{ + int i_; + + X& operator=(const X&); +public: + explicit X(int i) : i_(i) {} + X(const X& x) : i_(x.i_) {} + X& operator=(X&& x) + { + i_ = x.i_; + x.i_ = -1; + return *this; + } + + friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);} + + friend class Y; +}; + +class Y +{ + int i_; + + Y& operator=(const Y&); +public: + explicit Y(int i) : i_(i) {} + Y(const Y& y) : i_(y.i_) {} + void operator=(const X& x) {i_ = x.i_;} +}; + +#endif + + int main() { test<input_iterator<const int*>, output_iterator<int*> >(); @@ -71,4 +109,10 @@ int main() test<const int*, bidirectional_iterator<int*> >(); test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + X x[3] = {X(1), X(2), X(3)}; + Y y[3] = {Y(1), Y(2), Y(3)}; + std::adjacent_difference(x, x+3, y, std::minus<X>()); +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal1.fail.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal1.fail.cpp index 16641f2b57d..6ba0b30d458 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal1.fail.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal1.fail.cpp @@ -13,9 +13,9 @@ int main() { #if _LIBCPP_STD_VER > 11 - using namespace std; + using std::string; - std::string foo = ""s; // should fail w/conversion operator not found + string foo = ""s; // should fail w/conversion operator not found #else #error #endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal3.pass.cpp new file mode 100644 index 00000000000..98e3e40e058 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string.literals/literal3.pass.cpp @@ -0,0 +1,20 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#include <string> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std; + + string foo = ""s; +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/back.pass.cpp index f241d4d9125..ed0d327f52d 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/back.pass.cpp @@ -12,6 +12,10 @@ // const charT& back() const; // charT& back(); +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -42,4 +46,11 @@ int main() test(S("1234567890123456789012345678901234567890")); } #endif +#ifdef _LIBCPP_DEBUG + { + std::string s; + char c = s.back(); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp new file mode 100644 index 00000000000..b153249a717 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call back() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s(1, '\0'); + assert(s.back() == 0); + s.clear(); + assert(s.back() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s(1, '\0'); + assert(s.back() == 0); + s.clear(); + assert(s.back() == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cback.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cback.pass.cpp new file mode 100644 index 00000000000..ece27a6d654 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cback.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call back() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + const S s; + assert(s.back() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + const S s; + assert(s.back() == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cfront.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cfront.pass.cpp new file mode 100644 index 00000000000..d36885e36b7 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cfront.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call front() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + const S s; + assert(s.front() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + const S s; + assert(s.front() == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cindex.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cindex.pass.cpp new file mode 100644 index 00000000000..385c2197000 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_cindex.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Index const string out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + const S s; + assert(s[0] == 0); + assert(s[1] == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + const S s; + assert(s[0] == 0); + assert(s[1] == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_front.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_front.pass.cpp new file mode 100644 index 00000000000..15985facac1 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_front.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call front() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s(1, '\0'); + assert(s.front() == 0); + s.clear(); + assert(s.front() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s(1, '\0'); + assert(s.front() == 0); + s.clear(); + assert(s.front() == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_index.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_index.pass.cpp new file mode 100644 index 00000000000..82b11904369 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/db_index.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Index string out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s; + assert(s[0] == 0); + assert(s[1] == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s; + assert(s[0] == 0); + assert(s[1] == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/front.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/front.pass.cpp index ecfafb54bd0..807e936ab15 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/front.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/front.pass.cpp @@ -12,6 +12,10 @@ // const charT& front() const; // charT& front(); +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -42,4 +46,11 @@ int main() test(S("1234567890123456789012345678901234567890")); } #endif +#ifdef _LIBCPP_DEBUG + { + std::string s; + char c = s.front(); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/index.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/index.pass.cpp index b5643533b00..567eeee05ba 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/index.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.access/index.pass.cpp @@ -12,6 +12,10 @@ // const_reference operator[](size_type pos) const; // reference operator[](size_type pos); +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -47,4 +51,13 @@ int main() assert(s2[0] == '\0'); } #endif +#ifdef _LIBCPP_DEBUG + { + std::string s; + char c = s[0]; + assert(c == '\0'); + c = s[1]; + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp index e016bba56f6..0fe7f123c89 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp @@ -18,9 +18,45 @@ template <class S> void +test1(const S& s) +{ + S s2(s); + const size_t sz = s2.max_size() - 1; + try { s2.resize(sz, 'x'); } + catch ( const std::bad_alloc & ) { return ; } + assert ( s2.size() == sz ); +} + +template <class S> +void +test2(const S& s) +{ + S s2(s); + const size_t sz = s2.max_size(); + try { s2.resize(sz, 'x'); } + catch ( const std::bad_alloc & ) { return ; } + assert ( s.size() == sz ); +} + +template <class S> +void +test3(const S& s) +{ + S s2(s); + const size_t sz = s2.max_size() + 1; + try { s2.resize(sz, 'x'); } + catch ( const std::length_error & ) { return ; } + assert ( false ); +} + +template <class S> +void test(const S& s) { assert(s.max_size() >= s.size()); + test1(s); + test2(s); + test3(s); } int main() diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp new file mode 100644 index 00000000000..d9011f523cc --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Compare iterators from different containers with <. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s1; + S s2; + bool b = s1.begin() < s2.begin(); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s1; + S s2; + bool b = s1.begin() < s2.begin(); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp new file mode 100644 index 00000000000..3773dba3566 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Subtract iterators from different containers with <. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s1; + S s2; + int i = s1.begin() - s2.begin(); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s1; + S s2; + int i = s1.begin() - s2.begin(); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp new file mode 100644 index 00000000000..f82349a4e1d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Index iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string C; + C c(1, '\0'); + C::iterator i = c.begin(); + assert(i[0] == 0); + assert(i[1] == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C; + C c(1, '\0'); + C::iterator i = c.begin(); + assert(i[0] == 0); + assert(i[1] == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp new file mode 100644 index 00000000000..8324c873ccc --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Add to iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string C; + C c(1, '\0'); + C::iterator i = c.begin(); + i += 1; + assert(i == c.end()); + i = c.begin(); + i += 2; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C; + C c(1, '\0'); + C::iterator i = c.begin(); + i += 1; + assert(i == c.end()); + i = c.begin(); + i += 2; + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp new file mode 100644 index 00000000000..fff3907ab78 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Decrement iterator prior to begin. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string C; + C c(1, '\0'); + C::iterator i = c.end(); + --i; + assert(i == c.begin()); + --i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C; + C c(1, '\0'); + C::iterator i = c.end(); + --i; + assert(i == c.begin()); + --i; + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp new file mode 100644 index 00000000000..c36644ba2c0 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string C; + C c(1, '\0'); + C::iterator i = c.begin(); + ++i; + assert(i == c.end()); + ++i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C; + C c(1, '\0'); + C::iterator i = c.begin(); + ++i; + assert(i == c.end()); + ++i; + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp new file mode 100644 index 00000000000..d2b779b47aa --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string C; + C c(1, '\0'); + C::iterator i = c.end(); + char j = *i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C; + C c(1, '\0'); + C::iterator i = c.end(); + char j = *i; + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp new file mode 100644 index 00000000000..c9033dabdeb --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <cstdlib> +#include <exception> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string::const_iterator i = l1.end(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S::const_iterator i = l1.end(); + l1.erase(i); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp new file mode 100644 index 00000000000..be95fe2d415 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator position) with iterator from another container + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <cstdlib> +#include <exception> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string l2("123"); + std::string::const_iterator i = l2.begin(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S l2("123"); + S::const_iterator i = l2.begin(); + l1.erase(i); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp new file mode 100644 index 00000000000..1479171acdd --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator first, const_iterator last); with first iterator from another container + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <exception> +#include <cstdlib> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string l2("123"); + std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S l2("123"); + S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp new file mode 100644 index 00000000000..13f97b45b66 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator first, const_iterator last); with second iterator from another container + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <exception> +#include <cstdlib> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string l2("123"); + std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S l2("123"); + S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp new file mode 100644 index 00000000000..be3ee641b9f --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator first, const_iterator last); with both iterators from another container + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <exception> +#include <cstdlib> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string l2("123"); + std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S l2("123"); + S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp new file mode 100644 index 00000000000..c008196dcf0 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call erase(const_iterator first, const_iterator last); with a bad range + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <exception> +#include <cstdlib> + +#include "../../min_allocator.h" + +int main() +{ + { + std::string l1("123"); + std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S l1("123"); + S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp index aaff5b6debb..e84a3ba12ec 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp @@ -11,6 +11,10 @@ // void pop_back(); +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -41,4 +45,11 @@ int main() test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); } #endif +#if _LIBCPP_DEBUG >= 1 + { + std::string s; + s.pop_back(); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp index ec696feeff4..9eff67e7f01 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp @@ -11,6 +11,10 @@ // iterator insert(const_iterator p, charT c); +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <stdexcept> #include <cassert> @@ -72,4 +76,13 @@ int main() test(s, s.begin()+6, 'C', S("a567ABC1432dcb")); } #endif +#if _LIBCPP_DEBUG >= 1 + { + typedef std::string S; + S s; + S s2; + s.insert(s2.begin(), '1'); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp index 4e24935743e..8fc469e3133 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp @@ -11,6 +11,10 @@ // iterator insert(const_iterator p, initializer_list<charT> il); +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -34,5 +38,13 @@ int main() assert(s == "123abc456"); } #endif +#if _LIBCPP_DEBUG >= 1 + { + std::string s; + std::string s2; + s.insert(s2.begin(), {'a', 'b', 'c'}); + assert(false); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp index 0eb3216e0d5..593279cdbf5 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -12,6 +12,10 @@ // template<class InputIterator> // iterator insert(const_iterator p, InputIterator first, InputIterator last); +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -123,4 +127,14 @@ int main() S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } #endif +#if _LIBCPP_DEBUG >= 1 + { + std::string v; + std::string v2; + char a[] = "123"; + const int N = sizeof(a)/sizeof(a[0]); + std::string::iterator i = v.insert(v2.cbegin() + 10, a, a+N); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp index a3e5d29ee1e..e104072c73b 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp @@ -11,6 +11,10 @@ // iterator insert(const_iterator p, size_type n, charT c); +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <string> #include <cassert> @@ -166,4 +170,12 @@ int main() test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); } #endif +#if _LIBCPP_DEBUG >= 1 + { + std::string s; + std::string s2; + s.insert(s2.begin(), 1, 'a'); + assert(false); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp index 37262f13c77..bdc4519305b 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp @@ -26,10 +26,10 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S ex typename S::size_type old_size = s.size(); typename S::const_iterator first = s.begin() + pos1; typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; s.replace(first, last, f, l); assert(s.__invariants()); assert(s == expected); - typename S::size_type xlen = last - first; typename S::size_type rlen = std::distance(f, l); assert(s.size() == old_size - xlen + rlen); } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp index 58a4b20c2f2..6d552f0e747 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp @@ -27,10 +27,10 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S typename S::size_type old_size = s.size(); typename S::const_iterator first = s.begin() + pos1; typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; s.replace(first, last, str); assert(s.__invariants()); assert(s == expected); - typename S::size_type xlen = last - first; typename S::size_type rlen = S::traits_type::length(str); assert(s.size() == old_size - xlen + rlen); } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp index 0ef59ed7771..a8968ef7a3a 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp @@ -28,10 +28,10 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S typename S::size_type old_size = s.size(); typename S::const_iterator first = s.begin() + pos1; typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; s.replace(first, last, str, n2); assert(s.__invariants()); assert(s == expected); - typename S::size_type xlen = last - first; typename S::size_type rlen = n2; assert(s.size() == old_size - xlen + rlen); } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp index 6525607d7a7..b1b3d96ff94 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp @@ -28,10 +28,10 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, typename S::size typename S::size_type old_size = s.size(); typename S::const_iterator first = s.begin() + pos1; typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; s.replace(first, last, n2, c); assert(s.__invariants()); assert(s == expected); - typename S::size_type xlen = last - first; typename S::size_type rlen = n2; assert(s.size() == old_size - xlen + rlen); } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp index 76db558c2e5..95ef8be2de3 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp @@ -27,10 +27,10 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expecte typename S::size_type old_size = s.size(); typename S::const_iterator first = s.begin() + pos1; typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; s.replace(first, last, str); assert(s.__invariants()); assert(s == expected); - typename S::size_type xlen = last - first; typename S::size_type rlen = str.size(); assert(s.size() == old_size - xlen + rlen); } diff --git a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stol.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stol.pass.cpp index 0338ef18f45..d1cd75dcf17 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stol.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stol.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <string> diff --git a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoul.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoul.pass.cpp index dd42b7e9b70..fcd19e88355 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoul.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoul.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <string> diff --git a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoull.pass.cpp b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoull.pass.cpp index 19df70653c7..b1a2f9f0978 100644 --- a/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoull.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/strings/string.conversions/stoull.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // <string> diff --git a/external/bsd/libc++/dist/libcxx/test/support/platform_support.h b/external/bsd/libc++/dist/libcxx/test/support/platform_support.h index 7900bbf84a5..9ae2ae7cb2e 100644 --- a/external/bsd/libc++/dist/libcxx/test/support/platform_support.h +++ b/external/bsd/libc++/dist/libcxx/test/support/platform_support.h @@ -42,19 +42,18 @@ #include <stdio.h> #include <stdlib.h> #include <string> +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include <io.h> // _mktemp +#endif inline std::string get_temp_file_name() { -#ifdef _LIBCPP_MSVCRT - char* p = _tempnam( NULL, NULL ); - if (p == nullptr) - abort(); - std::string s(p); - free( p ); -#else std::string s("temp.XXXXXX"); +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) + _mktemp(&s[0]); +#else mktemp(&s[0]); #endif return s; diff --git a/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.overview/future_errc.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.overview/future_errc.pass.cpp index 6ffaca47427..7b3b70a39a6 100644 --- a/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.overview/future_errc.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.overview/future_errc.pass.cpp @@ -11,18 +11,18 @@ // enum class future_errc // { -// broken_promise, -// future_already_retrieved, +// future_already_retrieved = 1, // promise_already_satisfied, // no_state +// broken_promise, // }; #include <future> int main() { - static_assert(static_cast<int>(std::future_errc::broken_promise) == 0, ""); static_assert(static_cast<int>(std::future_errc::future_already_retrieved) == 1, ""); static_assert(static_cast<int>(std::future_errc::promise_already_satisfied) == 2, ""); static_assert(static_cast<int>(std::future_errc::no_state) == 3, ""); + static_assert(static_cast<int>(std::future_errc::broken_promise) == 4, ""); } diff --git a/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp new file mode 100644 index 00000000000..45048b747f7 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class packaged_task<R(ArgTypes...)> +// template <class F> +// packaged_task(F&& f); +// These constructors shall not participate in overload resolution if +// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. + +#include <future> +#include <cassert> + +struct A {}; +typedef std::packaged_task<A(int, char)> PT; +typedef volatile std::packaged_task<A(int, char)> VPT; + + +int main() +{ + PT p { VPT{} }; +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp new file mode 100644 index 00000000000..e81adfa6dcd --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class packaged_task<R(ArgTypes...)> +// template <class F, class Allocator> +// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); +// These constructors shall not participate in overload resolution if +// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. + +#include <future> +#include <cassert> + +#include "../../test_allocator.h" + +struct A {}; +typedef std::packaged_task<A(int, char)> PT; +typedef volatile std::packaged_task<A(int, char)> VPT; + +int main() +{ + PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}}; +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp new file mode 100644 index 00000000000..0bd347d0ba4 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock& operator=(shared_lock const&) = delete; + +#include <shared_mutex> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m0; +std::shared_mutex m1; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0(m0); + std::shared_lock<std::shared_mutex> lk1(m1); + lk1 = lk0; +#else +# error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp new file mode 100644 index 00000000000..66cec9ec58b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(shared_lock const&) = delete; + +#include <shared_mutex> + +#if _LIBCPP_STD_VER > 11 +std::shared_mutex m; +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0(m); + std::shared_lock<std::shared_mutex> lk = lk0; +#else +# error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp new file mode 100644 index 00000000000..2adef5f76f9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(); + +#include <shared_mutex> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> ul; + assert(!ul.owns_lock()); + assert(ul.mutex() == nullptr); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp new file mode 100644 index 00000000000..1fcc98fce96 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock& operator=(shared_lock&& u); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m0; +std::shared_mutex m1; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0(m0); + std::shared_lock<std::shared_mutex> lk1(m1); + lk1 = std::move(lk0); + assert(lk1.mutex() == &m0); + assert(lk1.owns_lock() == true); + assert(lk0.mutex() == nullptr); + assert(lk0.owns_lock() == false); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp new file mode 100644 index 00000000000..7e801da20f2 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(shared_lock&& u); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 +std::shared_mutex m; +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0(m); + std::shared_lock<std::shared_mutex> lk = std::move(lk0); + assert(lk.mutex() == &m); + assert(lk.owns_lock() == true); + assert(lk0.mutex() == nullptr); + assert(lk0.owns_lock() == false); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp new file mode 100644 index 00000000000..fd1dad42657 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// explicit shared_lock(mutex_type& m); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + time_point t1; + { + std::shared_lock<std::shared_mutex> ul(m); + t1 = Clock::now(); + } + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void g() +{ + time_point t0 = Clock::now(); + time_point t1; + { + std::shared_lock<std::shared_mutex> ul(m); + t1 = Clock::now(); + } + ns d = t1 - t0; + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + m.lock_shared(); + for (auto& t : v) + t = std::thread(g); + std::thread q(f); + std::this_thread::sleep_for(ms(250)); + m.unlock_shared(); + for (auto& t : v) + t.join(); + q.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp new file mode 100644 index 00000000000..9c4400555c3 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(mutex_type& m, adopt_lock_t); + +#include <shared_mutex> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_mutex m; + m.lock(); + std::shared_lock<std::shared_mutex> lk(m, std::adopt_lock); + assert(lk.mutex() == &m); + assert(lk.owns_lock() == true); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp new file mode 100644 index 00000000000..2f2247a0ed2 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(mutex_type& m, defer_lock_t); + +#include <shared_mutex> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_mutex m; + std::shared_lock<std::shared_mutex> lk(m, std::defer_lock); + assert(lk.mutex() == &m); + assert(lk.owns_lock() == false); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp new file mode 100644 index 00000000000..f3798af9c06 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class timed_mutex; + +// template <class Rep, class Period> +// shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + std::shared_lock<std::shared_mutex> lk(m, ms(300)); + assert(lk.owns_lock() == true); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + std::shared_lock<std::shared_mutex> lk(m, ms(250)); + assert(lk.owns_lock() == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f1)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f2)); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + for (auto& t : v) + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp new file mode 100644 index 00000000000..44eaee22ccd --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// template <class Clock, class Duration> +// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + std::shared_lock<std::shared_mutex> lk(m, Clock::now() + ms(300)); + assert(lk.owns_lock() == true); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ns(50000000)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + std::shared_lock<std::shared_mutex> lk(m, Clock::now() + ms(250)); + assert(lk.owns_lock() == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f1)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f2)); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + for (auto& t : v) + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp new file mode 100644 index 00000000000..9dae3f96bda --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// shared_lock(mutex_type& m, try_to_lock_t); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + { + std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + while (true) + { + std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock); + if (lk.owns_lock()) + break; + } + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(200)); // within 200ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp new file mode 100644 index 00000000000..c6617a51964 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// void lock(); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + std::shared_lock<std::shared_mutex> lk(m, std::defer_lock); + time_point t0 = Clock::now(); + lk.lock(); + time_point t1 = Clock::now(); + assert(lk.owns_lock() == true); + ns d = t1 - t0 - ms(250); + assert(d < ms(25)); // within 25ms + try + { + lk.lock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EDEADLK); + } + lk.unlock(); + lk.release(); + try + { + lk.lock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp new file mode 100644 index 00000000000..d65fbfafe6a --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// bool try_lock(); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +bool try_lock_called = false; + +struct mutex +{ + bool try_lock_shared() + { + try_lock_called = !try_lock_called; + return try_lock_called; + } + void unlock_shared() {} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk(m, std::defer_lock); + assert(lk.try_lock() == true); + assert(try_lock_called == true); + assert(lk.owns_lock() == true); + try + { + lk.try_lock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EDEADLK); + } + lk.unlock(); + assert(lk.try_lock() == false); + assert(try_lock_called == false); + assert(lk.owns_lock() == false); + lk.release(); + try + { + lk.try_lock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp new file mode 100644 index 00000000000..d076e529630 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// template <class Rep, class Period> +// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +bool try_lock_for_called = false; + +typedef std::chrono::milliseconds ms; + +struct mutex +{ + template <class Rep, class Period> + bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& rel_time) + { + assert(rel_time == ms(5)); + try_lock_for_called = !try_lock_for_called; + return try_lock_for_called; + } + void unlock_shared() {} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk(m, std::defer_lock); + assert(lk.try_lock_for(ms(5)) == true); + assert(try_lock_for_called == true); + assert(lk.owns_lock() == true); + try + { + lk.try_lock_for(ms(5)); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EDEADLK); + } + lk.unlock(); + assert(lk.try_lock_for(ms(5)) == false); + assert(try_lock_for_called == false); + assert(lk.owns_lock() == false); + lk.release(); + try + { + lk.try_lock_for(ms(5)); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp new file mode 100644 index 00000000000..8efffc46081 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// template <class Clock, class Duration> +// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +bool try_lock_until_called = false; + +struct mutex +{ + template <class Clock, class Duration> + bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& abs_time) + { + typedef std::chrono::milliseconds ms; + assert(Clock::now() - abs_time < ms(5)); + try_lock_until_called = !try_lock_until_called; + return try_lock_until_called; + } + void unlock_shared() {} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::chrono::steady_clock Clock; + std::shared_lock<mutex> lk(m, std::defer_lock); + assert(lk.try_lock_until(Clock::now()) == true); + assert(try_lock_until_called == true); + assert(lk.owns_lock() == true); + try + { + lk.try_lock_until(Clock::now()); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EDEADLK); + } + lk.unlock(); + assert(lk.try_lock_until(Clock::now()) == false); + assert(try_lock_until_called == false); + assert(lk.owns_lock() == false); + lk.release(); + try + { + lk.try_lock_until(Clock::now()); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp new file mode 100644 index 00000000000..9e4b3c8b9a1 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// void unlock(); + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +bool unlock_called = false; + +struct mutex +{ + void lock_shared() {} + void unlock_shared() {unlock_called = true;} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk(m); + lk.unlock(); + assert(unlock_called == true); + assert(lk.owns_lock() == false); + try + { + lk.unlock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } + lk.release(); + try + { + lk.unlock(); + assert(false); + } + catch (std::system_error& e) + { + assert(e.code().value() == EPERM); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp new file mode 100644 index 00000000000..6a7a39e9620 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// void swap(shared_lock& u) noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct mutex +{ + void lock_shared() {} + void unlock_shared() {} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk1(m); + std::shared_lock<mutex> lk2; + lk1.swap(lk2); + assert(lk1.mutex() == nullptr); + assert(lk1.owns_lock() == false); + assert(lk2.mutex() == &m); + assert(lk2.owns_lock() == true); + static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..03bf5e89bb7 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// template <class Mutex> +// void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct mutex +{ + void lock_shared() {} + void unlock_shared() {} +}; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk1(m); + std::shared_lock<mutex> lk2; + swap(lk1, lk2); + assert(lk1.mutex() == nullptr); + assert(lk1.owns_lock() == false); + assert(lk2.mutex() == &m); + assert(lk2.owns_lock() == true); + static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp new file mode 100644 index 00000000000..a836b35dfa1 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// mutex_type* release() noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct mutex +{ + static int lock_count; + static int unlock_count; + void lock_shared() {++lock_count;} + void unlock_shared() {++unlock_count;} +}; + +int mutex::lock_count = 0; +int mutex::unlock_count = 0; + +mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<mutex> lk(m); + assert(lk.mutex() == &m); + assert(lk.owns_lock() == true); + assert(mutex::lock_count == 1); + assert(mutex::unlock_count == 0); + assert(lk.release() == &m); + assert(lk.mutex() == nullptr); + assert(lk.owns_lock() == false); + assert(mutex::lock_count == 1); + assert(mutex::unlock_count == 0); + static_assert(noexcept(lk.release()), "release must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp new file mode 100644 index 00000000000..927e9d1d48d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// mutex_type *mutex() const noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0; + assert(lk0.mutex() == nullptr); + std::shared_lock<std::shared_mutex> lk1(m); + assert(lk1.mutex() == &m); + lk1.unlock(); + assert(lk1.mutex() == &m); + static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp new file mode 100644 index 00000000000..901ccbc1533 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// explicit operator bool() const noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0; + assert(static_cast<bool>(lk0) == false); + std::shared_lock<std::shared_mutex> lk1(m); + assert(static_cast<bool>(lk1) == true); + lk1.unlock(); + assert(static_cast<bool>(lk1) == false); + static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp new file mode 100644 index 00000000000..ca4715b67d1 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> class shared_lock; + +// bool owns_lock() const noexcept; + +#include <shared_mutex> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock<std::shared_mutex> lk0; + assert(lk0.owns_lock() == false); + std::shared_lock<std::shared_mutex> lk1(m); + assert(lk1.owns_lock() == true); + lk1.unlock(); + assert(lk1.owns_lock() == false); + static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp new file mode 100644 index 00000000000..353735739b3 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// template <class Mutex> +// class shared_lock +// { +// public: +// typedef Mutex mutex_type; +// ... +// }; + +#include <shared_mutex> +#include <type_traits> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::shared_lock<std::mutex>::mutex_type, + std::mutex>::value), ""); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp index 0efe7d64de4..4252de15146 100644 --- a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp @@ -11,7 +11,7 @@ // template <class Mutex> class unique_lock; -// void swap(unique_lock& u); +// mutex_type* release() noexcept; #include <mutex> #include <cassert> diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/nothing_to_do.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/assign.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/assign.fail.cpp new file mode 100644 index 00000000000..1405a22c524 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/assign.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// shared_mutex& operator=(const shared_mutex&) = delete; + +#include <shared_mutex> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_mutex m0; + std::shared_mutex m1; + m1 = m0; +#else +# error +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/copy.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/copy.fail.cpp new file mode 100644 index 00000000000..7e699232ae7 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/copy.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// shared_mutex(const shared_mutex&) = delete; + +#include <shared_mutex> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_mutex m0; + std::shared_mutex m1(m0); +#else +# error +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/default.pass.cpp new file mode 100644 index 00000000000..060fb924375 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/default.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// shared_mutex(); + +#include <shared_mutex> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_mutex m; +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock.pass.cpp new file mode 100644 index 00000000000..2fd78008151 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// void lock(); + +#include <shared_mutex> +#include <thread> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + m.lock(); + time_point t1 = Clock::now(); + m.unlock(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::thread t(f); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + t.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock_shared.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock_shared.pass.cpp new file mode 100644 index 00000000000..6fe1b446950 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock_shared.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// void lock_shared(); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + m.lock_shared(); + time_point t1 = Clock::now(); + m.unlock_shared(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void g() +{ + time_point t0 = Clock::now(); + m.lock_shared(); + time_point t1 = Clock::now(); + m.unlock_shared(); + ns d = t1 - t0; + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + m.lock_shared(); + for (auto& t : v) + t = std::thread(g); + std::thread q(f); + std::this_thread::sleep_for(ms(250)); + m.unlock_shared(); + for (auto& t : v) + t.join(); + q.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock.pass.cpp new file mode 100644 index 00000000000..86aa0c4e5c2 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// bool try_lock(); + +#include <shared_mutex> +#include <thread> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + assert(!m.try_lock()); + assert(!m.try_lock()); + assert(!m.try_lock()); + while(!m.try_lock()) + ; + time_point t1 = Clock::now(); + m.unlock(); + ns d = t1 - t0 - ms(250); + assert(d < ms(200)); // within 200ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::thread t(f); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + t.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_for.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_for.pass.cpp new file mode 100644 index 00000000000..1560359961f --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_for.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// template <class Rep, class Period> +// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + +#include <shared_mutex> +#include <thread> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_for(ms(300)) == true); + time_point t1 = Clock::now(); + m.unlock(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_for(ms(250)) == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::thread t(f1); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + t.join(); + } + { + m.lock(); + std::thread t(f2); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared.pass.cpp new file mode 100644 index 00000000000..da859ab9974 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// bool try_lock_shared(); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::system_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f() +{ + time_point t0 = Clock::now(); + assert(!m.try_lock_shared()); + assert(!m.try_lock_shared()); + assert(!m.try_lock_shared()); + while(!m.try_lock_shared()) + ; + time_point t1 = Clock::now(); + m.unlock_shared(); + ns d = t1 - t0 - ms(250); + assert(d < ms(200)); // within 200ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_for.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_for.pass.cpp new file mode 100644 index 00000000000..b1d6e4c6a52 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_for.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// template <class Rep, class Period> +// bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_shared_for(ms(300)) == true); + time_point t1 = Clock::now(); + m.unlock_shared(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_shared_for(ms(250)) == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f1)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f2)); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + for (auto& t : v) + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_until.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_until.pass.cpp new file mode 100644 index 00000000000..3dbf0c7bd73 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_until.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// template <class Clock, class Duration> +// bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time); + +#include <shared_mutex> +#include <thread> +#include <vector> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true); + time_point t1 = Clock::now(); + m.unlock_shared(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f1)); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock(); + std::vector<std::thread> v; + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f2)); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + for (auto& t : v) + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_until.pass.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_until.pass.cpp new file mode 100644 index 00000000000..44f91f0afb5 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_until.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <shared_mutex> + +// class shared_mutex; + +// template <class Clock, class Duration> +// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + +#include <shared_mutex> +#include <thread> +#include <cstdlib> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +std::shared_mutex m; + +typedef std::chrono::steady_clock Clock; +typedef Clock::time_point time_point; +typedef Clock::duration duration; +typedef std::chrono::milliseconds ms; +typedef std::chrono::nanoseconds ns; + +void f1() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_until(Clock::now() + ms(300)) == true); + time_point t1 = Clock::now(); + m.unlock(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +void f2() +{ + time_point t0 = Clock::now(); + assert(m.try_lock_until(Clock::now() + ms(250)) == false); + time_point t1 = Clock::now(); + ns d = t1 - t0 - ms(250); + assert(d < ms(50)); // within 50ms +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + m.lock(); + std::thread t(f1); + std::this_thread::sleep_for(ms(250)); + m.unlock(); + t.join(); + } + { + m.lock(); + std::thread t(f2); + std::this_thread::sleep_for(ms(300)); + m.unlock(); + t.join(); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/external/bsd/libc++/dist/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp new file mode 100644 index 00000000000..a331add9626 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <thread> + +// class thread +// template <class _Fp, class ..._Args, +// explicit thread(_Fp&& __f, _Args&&... __args); +// This constructor shall not participate in overload resolution +// if decay<F>::type is the same type as std::thread. + + +#include <thread> +#include <cassert> + +int main() +{ + volatile std::thread t1; + std::thread t2 ( t1, 1, 2.0 ); +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp index 5eeba18b657..74298f23b7c 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(36, 4) == 9); assert(f2(36.0, 4) == 9); assert(f2(18, 4.0) == 4.5); // exact in binary + + constexpr int foo = std::divides<int> () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::divides<> () (3.0, 2); + static_assert ( bar == 1, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp index 2a8ecd6b876..9a496a8066c 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(3,2) == 1); assert(f2(3.0, 2) == 1); assert(f2(3, 2.5) == 0.5); + + constexpr int foo = std::minus<int> () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::minus<> () (3.0, 2); + static_assert ( bar == 1, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp index 421f9452d62..3c178819231 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(36, 8) == 4); assert(f2(36L, 8) == 4); assert(f2(36, 8L) == 4); + + constexpr int foo = std::modulus<int> () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::modulus<> () (3L, 2); + static_assert ( bar == 1, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp index 67bb5a5e3d0..97287e6c8da 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(3,2) == 6); assert(f2(3.0, 2) == 6); assert(f2(3, 2.5) == 7.5); // exact in binary + + constexpr int foo = std::multiplies<int> () (3, 2); + static_assert ( foo == 6, "" ); + + constexpr int bar = std::multiplies<> () (3.0, 2); + static_assert ( bar == 6, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp index 181c1fb7aa8..3ffb7051bfd 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(36) == -36); assert(f2(36L) == -36); assert(f2(36.0) == -36); + + constexpr int foo = std::negate<int> () (3); + static_assert ( foo == -3, "" ); + + constexpr int bar = std::negate<> () (3.0); + static_assert ( bar == -3, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp index 4de23fff086..44001a0e5f4 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp @@ -27,5 +27,11 @@ int main() assert(f2(3,2) == 5); assert(f2(3.0, 2) == 5); assert(f2(3, 2.5) == 5.5); + + constexpr int foo = std::plus<int> () (3, 2); + static_assert ( foo == 5, "" ); + + constexpr int bar = std::plus<> () (3.0, 2); + static_assert ( bar == 5, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp index 1841232728e..66544781d9d 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp @@ -47,5 +47,11 @@ int main() assert(f2(0xFFFF, 0x58D3) == 0x58D3); assert(f2(0xFFFFL, 0x58D3) == 0x58D3); assert(f2(0xFFFF, 0x58D3L) == 0x58D3); + + constexpr int foo = std::bit_and<int> () (0x58D3, 0xEA95); + static_assert ( foo == 0x4891, "" ); + + constexpr int bar = std::bit_and<> () (0x58D3L, 0xEA95); + static_assert ( bar == 0x4891, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp index 2158292f435..82efcbc29fa 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp @@ -36,5 +36,11 @@ int main() assert((f2(0L) & 0xFFFF ) == 0xFFFF); assert((f2(0xFFFF) & 0xFFFF ) == 0); assert((f2(0xFFFFL) & 0xFFFF ) == 0); + + constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF; + static_assert ( foo == 0x156A, "" ); + + constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF; + static_assert ( bar == 0x156A, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp index 21ada1270ac..6ae3c3ac978 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp @@ -47,5 +47,11 @@ int main() assert(f2(0xFFFF, 0x58D3) == 0xFFFF); assert(f2(0xFFFFL, 0x58D3) == 0xFFFF); assert(f2(0xFFFF, 0x58D3L) == 0xFFFF); + + constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95); + static_assert ( foo == 0xFAD7, "" ); + + constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95); + static_assert ( bar == 0xFAD7, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp index 8417d6ed25e..e7bb5e49f94 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp @@ -47,5 +47,11 @@ int main() assert(f(0xFFFF, 0x58D3) == 0xA72C); assert(f(0xFFFFL, 0x58D3) == 0xA72C); assert(f(0xFFFF, 0x58D3L) == 0xA72C); + + constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95); + static_assert ( foo == 0xB246, "" ); + + constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95); + static_assert ( bar == 0xB246, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp index 7904887c686..3d1c0b5cecd 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp @@ -29,5 +29,11 @@ int main() assert(!f2(36, 6)); assert(f2(36, 36.0)); assert(f2(36.0, 36L)); + + constexpr bool foo = std::equal_to<int> () (36, 36); + static_assert ( foo, "" ); + + constexpr bool bar = std::equal_to<> () (36.0, 36); + static_assert ( bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp index 8e9a8919296..5a88f4362dc 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp @@ -33,5 +33,11 @@ int main() assert( f2(36.0, 6)); assert(!f2(6, 36.0)); assert(!f2(6.0, 36)); + + constexpr bool foo = std::greater<int> () (36, 36); + static_assert ( !foo, "" ); + + constexpr bool bar = std::greater<> () (36.0, 36); + static_assert ( !bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp index 63aad6751a7..22444c79420 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp @@ -33,5 +33,11 @@ int main() assert( f2(36.0, 6)); assert(!f2(6, 36.0)); assert(!f2(6.0, 36)); + + constexpr bool foo = std::greater_equal<int> () (36, 36); + static_assert ( foo, "" ); + + constexpr bool bar = std::greater_equal<> () (36.0, 36); + static_assert ( bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp index 606096435a2..99cdd1291bb 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp @@ -33,5 +33,11 @@ int main() assert(!f2(36.0, 6)); assert( f2(6, 36.0)); assert( f2(6.0, 36)); + + constexpr bool foo = std::less<int> () (36, 36); + static_assert ( !foo, "" ); + + constexpr bool bar = std::less<> () (36.0, 36); + static_assert ( !bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp index 346e68b9768..116906eaafe 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp @@ -33,5 +33,11 @@ int main() assert(!f2(36.0, 6)); assert( f2(6, 36.0)); assert( f2(6.0, 36)); + + constexpr bool foo = std::less_equal<int> () (36, 36); + static_assert ( foo, "" ); + + constexpr bool bar = std::less_equal<> () (36.0, 36); + static_assert ( bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp index d481e47c449..4b61bf8b838 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp @@ -31,5 +31,11 @@ int main() assert( f2(36.0, 6)); assert(!f2(36.0, 36)); assert(!f2(36, 36.0)); + + constexpr bool foo = std::not_equal_to<int> () (36, 36); + static_assert ( !foo, "" ); + + constexpr bool bar = std::not_equal_to<> () (36.0, 36); + static_assert ( !bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp index 4302f771046..c7b03cce095 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp @@ -38,5 +38,11 @@ int main() assert( f2(36L, 36)); assert(!f2(36L, 0)); assert(!f2(0L, 36)); + + constexpr bool foo = std::logical_and<int> () (36, 36); + static_assert ( foo, "" ); + + constexpr bool bar = std::logical_and<> () (36.0, 36); + static_assert ( bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp index 40a475445bc..12b3543c5c6 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp @@ -29,5 +29,11 @@ int main() assert( f2(0)); assert(!f2(36L)); assert( f2(0L)); + + constexpr bool foo = std::logical_not<int> () (36); + static_assert ( !foo, "" ); + + constexpr bool bar = std::logical_not<> () (36); + static_assert ( !bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp index 1c9b243c16d..8b5420d8e04 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp @@ -37,5 +37,11 @@ int main() assert(!f2(0, 0)); assert(!f2(0, 0L)); assert(!f2(0L, 0)); + + constexpr bool foo = std::logical_or<int> () (36, 36); + static_assert ( foo, "" ); + + constexpr bool bar = std::logical_or<> () (36.0, 36); + static_assert ( bar, "" ); #endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.fail.cpp new file mode 100644 index 00000000000..9e44bfb7781 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// Hashing a struct w/o a defined hash should fail. + +#include <functional> +#include <cassert> +#include <type_traits> + +struct X {}; + +int main() +{ + X x; + size_t h = std::hash<X>{} ( x ); +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.pass.cpp new file mode 100644 index 00000000000..b5cd6f8454d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/function.objects/unord.hash/enum.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// make sure that we can hash enumeration values +// Not very portable + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include <functional> +#include <cassert> +#include <type_traits> +#include <limits> + +enum class Colors { red, orange, yellow, green, blue, indigo, violet }; +enum class Cardinals { zero, one, two, three, five=5 }; +enum class LongColors : short { red, orange, yellow, green, blue, indigo, violet }; +enum class ShortColors : long { red, orange, yellow, green, blue, indigo, violet }; +enum class EightBitColors : uint8_t { red, orange, yellow, green, blue, indigo, violet }; + +enum Fruits { apple, pear, grape, mango, cantaloupe }; + +template <class T> +void +test() +{ + static_assert((std::is_base_of<std::unary_function<T, std::size_t>, + std::hash<T> >::value), ""); + typedef typename std::underlying_type<T>::type under_type; + + std::hash<T> h1; + std::hash<under_type> h2; + for (int i = 0; i <= 5; ++i) + { + T t(static_cast<T> (i)); + if (sizeof(T) <= sizeof(std::size_t)) + assert(h1(t) == h2(static_cast<under_type>(i))); + } +} + +int main() +{ + test<Cardinals>(); + + test<Colors>(); + test<ShortColors>(); + test<LongColors>(); + test<EightBitColors>(); + + test<Fruits>(); +} +#else +int main () {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp index 86a365144ba..1fa7291203e 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp @@ -12,7 +12,7 @@ // template <class Alloc> // struct allocator_traits // { -// static size_type max_size(const allocator_type& a); +// static size_type max_size(const allocator_type& a) noexcept; // ... // }; @@ -61,4 +61,10 @@ int main() const B<int> b = {}; assert(std::allocator_traits<B<int> >::max_size(b) == 100); } +#if __cplusplus >= 201103 + { + std::allocator<int> a; + static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, ""); + } +#endif } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 7f01e4ba0a7..91bf7e7654e 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -18,10 +18,24 @@ int main() static_assert((std::is_same<std::common_type<int>::type, int>::value), ""); static_assert((std::is_same<std::common_type<char>::type, char>::value), ""); #if _LIBCPP_STD_VER > 11 - static_assert((std::is_same<std::common_type_t<int>, int>::value), ""); + static_assert((std::is_same<std::common_type_t<int>, int>::value), ""); static_assert((std::is_same<std::common_type_t<char>, char>::value), ""); #endif + static_assert((std::is_same<std::common_type< int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type< volatile int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<volatile long, int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<double, char>::type, double>::value), ""); static_assert((std::is_same<std::common_type<short, char>::type, int>::value), ""); #if _LIBCPP_STD_VER > 11 diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp index 6e265a05a8d..2dd4d9ac97c 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp @@ -17,7 +17,7 @@ enum Enum {zero, one_}; enum BigEnum { - bzero, + bigzero, big = 0xFFFFFFFFFFFFFFFFULL }; diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp index 5e432b5231d..6700b6cbb95 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp @@ -17,7 +17,7 @@ enum Enum {zero, one_}; enum BigEnum { - bzero, + bigzero, big = 0xFFFFFFFFFFFFFFFFULL }; diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp index 984a6c0b9d7..f4dd356383a 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_array_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert( std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp index e83dcf0e1a0..0de00485572 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_class_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp index 5e0c96126ac..7c9c78fcf2b 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_enum_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp index 88140049ea5..28664496031 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_floating_point_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert( std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp index 7989b96d7ed..82757f5035b 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_function_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp index 752ab0070ad..7d3b0f8beb1 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_integral_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert( std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp index 9d8ddcb13d4..3b6ccade7e7 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_lvalue_ref() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp index 210bbd7e4d4..dc317c55e28 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_member_function_pointer_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp index 25666fdea02..4e6699cc3e7 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_member_object_pointer_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp new file mode 100644 index 00000000000..d619701db23 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// nullptr_t +// is_null_pointer + +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 +template <class T> +void test_nullptr_imp() +{ + static_assert(!std::is_void<T>::value, ""); + static_assert( std::is_null_pointer<T>::value, ""); + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_nullptr() +{ + test_nullptr_imp<T>(); + test_nullptr_imp<const T>(); + test_nullptr_imp<volatile T>(); + test_nullptr_imp<const volatile T>(); +} + +int main() +{ + test_nullptr<std::nullptr_t>(); +} +#else +int main() {} +#endif diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp index 6f6f1d301fe..7073c106b44 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_pointer_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp index efc3294183b..79644240363 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_rvalue_ref() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp index 127f9f944af..6cabb717c0c 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_union_imp() { static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp index d50a3762ac0..f20bcf87ea1 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp @@ -17,6 +17,9 @@ template <class T> void test_void_imp() { static_assert( std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif static_assert(!std::is_integral<T>::value, ""); static_assert(!std::is_floating_point<T>::value, ""); static_assert(!std::is_array<T>::value, ""); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp new file mode 100644 index 00000000000..de27b982022 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// extension + +// template <typename _Tp> struct __has_operator_addressof + + +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + +struct A +{ +}; + +struct B +{ + constexpr B* operator&() const; +}; + +struct D; + +struct C +{ + template <class U> + D operator,(U&&); +}; + +struct E +{ + constexpr C operator&() const; +}; + +#endif // _LIBCPP_HAS_NO_CONSTEXPR + +int main() +{ +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::__has_operator_addressof<int>::value == false, ""); + static_assert(std::__has_operator_addressof<A>::value == false, ""); + static_assert(std::__has_operator_addressof<B>::value == true, ""); + static_assert(std::__has_operator_addressof<E>::value == true, ""); +#endif // _LIBCPP_HAS_NO_CONSTEXPR +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp index 8c21c759fa1..e4af6de1c83 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -34,6 +34,19 @@ void test_is_not_assignable() static_assert((!std::is_assignable<T, U>::value), ""); } +struct D; + +struct C +{ + template <class U> + D operator,(U&&); +}; + +struct E +{ + C operator=(int); +}; + int main() { test_is_assignable<int&, int&> (); @@ -41,6 +54,7 @@ int main() test_is_assignable<int&, double> (); test_is_assignable<B, A> (); test_is_assignable<void*&, void*> (); + test_is_assignable<E, int> (); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test_is_not_assignable<int, int&> (); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp index b4432dff7cd..5cabb381db5 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp @@ -57,6 +57,8 @@ struct A ~A(); }; +typedef void (Function) (); + int main() { test_is_destructible<A>(); @@ -77,4 +79,5 @@ int main() #if __has_feature(cxx_access_control_sfinae) test_is_not_destructible<NotEmpty>(); #endif + test_is_not_destructible<Function>(); } diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp index 547c346cd61..d65882378fc 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp @@ -19,8 +19,8 @@ void test_is_trivially_copyable() { static_assert( std::is_trivially_copyable<T>::value, ""); static_assert( std::is_trivially_copyable<const T>::value, ""); - static_assert( std::is_trivially_copyable<volatile T>::value, ""); - static_assert( std::is_trivially_copyable<const volatile T>::value, ""); + static_assert(!std::is_trivially_copyable<volatile T>::value, ""); + static_assert(!std::is_trivially_copyable<const volatile T>::value, ""); } template <class T> diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp new file mode 100644 index 00000000000..f321da6c4c3 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access; +// explicit bad_optional_access(const char* what_arg); + +#include <optional> +#include <string> +#include <cstring> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + const char* s = "message"; + std::bad_optional_access e(s); + assert(std::strcmp(e.what(), s) == 0); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp new file mode 100644 index 00000000000..353bbe438f8 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access; +// bad_optional_access& operator=(const bad_optional_access&); + +#include <optional> +#include <string> +#include <cstring> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_nothrow_copy_assignable<std::bad_optional_access>::value, ""); + const std::string s1("one message"); + const std::string s2("another message"); + std::bad_optional_access e1(s1); + std::bad_optional_access e2(s2); + assert(std::strcmp(e1.what(), e2.what()) != 0); + e1 = e2; + assert(std::strcmp(e1.what(), e2.what()) == 0); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp new file mode 100644 index 00000000000..cab8aed4f51 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access; +// bad_optional_access(const bad_optional_access&); + +#include <optional> +#include <string> +#include <cstring> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_nothrow_copy_constructible<std::bad_optional_access>::value, ""); + const std::string s("another message"); + std::bad_optional_access e1(s); + std::bad_optional_access e2 = e1; + assert(std::strcmp(e1.what(), e2.what()) == 0); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp new file mode 100644 index 00000000000..96ff10449a3 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access is not default constructible + +#include <optional> +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_default_constructible<std::bad_optional_access>::value, ""); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp new file mode 100644 index 00000000000..87d5cb640b9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access : public logic_error + +#include <optional> +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_base_of<std::logic_error, std::bad_optional_access>::value, ""); + static_assert(std::is_convertible<std::bad_optional_access*, std::logic_error*>::value, ""); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp new file mode 100644 index 00000000000..8658906498c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// class bad_optional_access; +// explicit bad_optional_access(const string& what_arg); + +#include <optional> +#include <string> +#include <cstring> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + const std::string s("message"); + std::bad_optional_access e(s); + assert(std::strcmp(e.what(), s.c_str()) == 0); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp new file mode 100644 index 00000000000..e833b22a386 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> constexpr bool operator==(const optional<T>& x, const T& v); +// template <class T> constexpr bool operator==(const T& v, const optional<T>& x); + +#include <optional> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} +}; + +constexpr bool operator == ( const X &lhs, const X &rhs ) + { return lhs.i_ == rhs.i_ ; } + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef X T; + typedef std::optional<T> O; + + constexpr T val(2); + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert ( !(o1 == T(1)), "" ); + static_assert ( o2 == T(1), "" ); + static_assert ( !(o3 == T(1)), "" ); + static_assert ( o3 == T(2) , "" ); + static_assert ( o3 == val, "" ); + + static_assert ( !(T(1) == o1), "" ); + static_assert ( T(1) == o2, "" ); + static_assert ( !(T(1) == o3), "" ); + static_assert ( T(2) == o3 , "" ); + static_assert ( val == o3 , "" ); + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp new file mode 100644 index 00000000000..e8bb1dcda19 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> constexpr bool operator<(const optional<T>& x, const T& v); +// template <class T> constexpr bool operator<(const T& v, const optional<T>& x); + +#include <optional> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} +}; + +constexpr bool operator < ( const X &lhs, const X &rhs ) + { return lhs.i_ < rhs.i_ ; } + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + + { + typedef X T; + typedef std::optional<T> O; + + constexpr T val(2); + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert ( o1 < T(1) , "" ); + static_assert ( !(o2 < T(1)), "" ); + static_assert ( !(o3 < T(1)), "" ); + static_assert ( o2 < T(2) , "" ); + static_assert ( o2 < T(val), "" ); + static_assert ( o3 < T(3) , "" ); + + static_assert ( !(T(1) < o1), "" ); + static_assert ( !(T(1) < o2), "" ); + static_assert ( T(1) < o3 , "" ); + static_assert ( !(T(2) < o2), "" ); + static_assert (!(T(val) < o2), "" ); + static_assert ( !(T(3) < o3), "" ); + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.general/nothing_to_do.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.general/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.general/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.hash/hash.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.hash/hash.pass.cpp new file mode 100644 index 00000000000..406632ae1fc --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.hash/hash.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> struct hash<optional<T>>; + +#include <optional> +#include <string> +#include <memory> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + std::optional<T> opt; + assert(std::hash<std::optional<T>>{}(opt) == 0); + opt = 2; + assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt)); + } + { + typedef std::string T; + std::optional<T> opt; + assert(std::hash<std::optional<T>>{}(opt) == 0); + opt = std::string("123"); + assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt)); + } + { + typedef std::unique_ptr<int> T; + std::optional<T> opt; + assert(std::hash<std::optional<T>>{}(opt) == 0); + opt = std::unique_ptr<int>(new int(3)); + assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt)); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.inplace/in_place_t.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.inplace/in_place_t.pass.cpp new file mode 100644 index 00000000000..f1728b48cc0 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.inplace/in_place_t.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// struct in_place_t{}; +// constexpr in_place_t in_place{}; + +#include <optional> +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +constexpr +int +test(const std::in_place_t&) +{ + return 3; +} + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + + static_assert((std::is_class<std::in_place_t>::value), ""); + static_assert((std::is_empty<std::in_place_t>::value), ""); + + static_assert(test(std::in_place) == 3, ""); +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp new file mode 100644 index 00000000000..bfc8e16e36a --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +// <optional> + +// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept; +// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept; + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef std::optional<T> O; + + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + + static_assert ( std::nullopt == o1 , "" ); + static_assert ( !(std::nullopt == o2), "" ); + static_assert ( o1 == std::nullopt , "" ); + static_assert ( !(o2 == std::nullopt), "" ); + + static_assert (noexcept(std::nullopt == o1), ""); + static_assert (noexcept(o1 == std::nullopt), ""); + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp new file mode 100644 index 00000000000..ea297ca7e7d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +// <optional> + +// template <class T> constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept; +// template <class T> constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept; + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef std::optional<T> O; + + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + + static_assert ( !(std::nullopt < o1), "" ); + static_assert ( std::nullopt < o2 , "" ); + static_assert ( !(o1 < std::nullopt), "" ); + static_assert ( !(o2 < std::nullopt), "" ); + + static_assert (noexcept(std::nullopt < o1), ""); + static_assert (noexcept(o1 < std::nullopt), ""); + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp new file mode 100644 index 00000000000..bb8ec43f317 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// struct nullopt_t{see below}; +// constexpr nullopt_t nullopt(unspecified); + +#include <optional> +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +constexpr +int +test(const std::nullopt_t&) +{ + return 3; +} + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_class<std::nullopt_t>::value), ""); + static_assert((std::is_empty<std::nullopt_t>::value), ""); + static_assert((std::is_literal_type<std::nullopt_t>::value), ""); + static_assert((!std::is_default_constructible<std::nullopt_t>::value), ""); + + static_assert(test(std::nullopt) == 3, ""); +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp new file mode 100644 index 00000000000..ee3b1544400 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class U> optional<T>& operator=(U&& v); + +#include <optional> +#include <type_traits> +#include <cassert> +#include <memory> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_assignable<std::optional<int>, int>::value, ""); + static_assert(std::is_assignable<std::optional<int>, int&>::value, ""); + static_assert(std::is_assignable<std::optional<int>&, int>::value, ""); + static_assert(std::is_assignable<std::optional<int>&, int&>::value, ""); + static_assert(std::is_assignable<std::optional<int>&, const int&>::value, ""); + static_assert(!std::is_assignable<const std::optional<int>&, const int&>::value, ""); + static_assert(!std::is_assignable<std::optional<int>, X>::value, ""); + { + std::optional<int> opt; + opt = 1; + assert(static_cast<bool>(opt) == true); + assert(*opt == 1); + } + { + std::optional<int> opt; + const int i = 2; + opt = i; + assert(static_cast<bool>(opt) == true); + assert(*opt == i); + } + { + std::optional<int> opt(3); + const int i = 2; + opt = i; + assert(static_cast<bool>(opt) == true); + assert(*opt == i); + } + { + std::optional<std::unique_ptr<int>> opt; + opt = std::unique_ptr<int>(new int(3)); + assert(static_cast<bool>(opt) == true); + assert(**opt == 3); + } + { + std::optional<std::unique_ptr<int>> opt(std::unique_ptr<int>(new int(2))); + opt = std::unique_ptr<int>(new int(3)); + assert(static_cast<bool>(opt) == true); + assert(**opt == 3); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp new file mode 100644 index 00000000000..f6d365ae1de --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// optional<T>& operator=(const optional<T>& rhs); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + static bool throw_now; + + X() = default; + X(const X&) + { + if (throw_now) + throw 6; + } +}; + +bool X::throw_now = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt; + constexpr std::optional<int> opt2; + opt = opt2; + static_assert(static_cast<bool>(opt2) == false, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + } + { + std::optional<int> opt; + constexpr std::optional<int> opt2(2); + opt = opt2; + static_assert(static_cast<bool>(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + assert(*opt == *opt2); + } + { + std::optional<int> opt(3); + constexpr std::optional<int> opt2; + opt = opt2; + static_assert(static_cast<bool>(opt2) == false, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + } + { + std::optional<int> opt(3); + constexpr std::optional<int> opt2(2); + opt = opt2; + static_assert(static_cast<bool>(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + assert(*opt == *opt2); + } + { + std::optional<X> opt; + std::optional<X> opt2(X{}); + assert(static_cast<bool>(opt2) == true); + try + { + X::throw_now = true; + opt = opt2; + assert(false); + } + catch (int i) + { + assert(i == 6); + assert(static_cast<bool>(opt) == false); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp new file mode 100644 index 00000000000..e43e8800639 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -0,0 +1,146 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class... Args> void optional<T>::emplace(Args&&... args); + +#include <optional> +#include <type_traits> +#include <cassert> +#include <memory> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; + int j_ = 0; +public: + X() : i_(0) {} + X(int i) : i_(i) {} + X(int i, int j) : i_(i), j_(j) {} + + friend bool operator==(const X& x, const X& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Y +{ +public: + static bool dtor_called; + Y() = default; + ~Y() {dtor_called = true;} +}; + +bool Y::dtor_called = false; + +class Z +{ +public: + static bool dtor_called; + Z() = default; + Z(int) {throw 6;} + ~Z() {dtor_called = true;} +}; + +bool Z::dtor_called = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt; + opt.emplace(); + assert(static_cast<bool>(opt) == true); + assert(*opt == 0); + } + { + std::optional<int> opt; + opt.emplace(1); + assert(static_cast<bool>(opt) == true); + assert(*opt == 1); + } + { + std::optional<int> opt(2); + opt.emplace(); + assert(static_cast<bool>(opt) == true); + assert(*opt == 0); + } + { + std::optional<int> opt(2); + opt.emplace(1); + assert(static_cast<bool>(opt) == true); + assert(*opt == 1); + } + { + std::optional<X> opt; + opt.emplace(); + assert(static_cast<bool>(opt) == true); + assert(*opt == X()); + } + { + std::optional<X> opt; + opt.emplace(1); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(1)); + } + { + std::optional<X> opt; + opt.emplace(1, 2); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(1, 2)); + } + { + std::optional<X> opt(X{3}); + opt.emplace(); + assert(static_cast<bool>(opt) == true); + assert(*opt == X()); + } + { + std::optional<X> opt(X{3}); + opt.emplace(1); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(1)); + } + { + std::optional<X> opt(X{3}); + opt.emplace(1, 2); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(1, 2)); + } + { + Y y; + { + std::optional<Y> opt(y); + assert(Y::dtor_called == false); + opt.emplace(); + assert(Y::dtor_called == true); + } + } + { + Z z; + std::optional<Z> opt(z); + try + { + assert(static_cast<bool>(opt) == true); + assert(Z::dtor_called == false); + opt.emplace(1); + } + catch (int i) + { + assert(i == 6); + assert(static_cast<bool>(opt) == false); + assert(Z::dtor_called == true); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp new file mode 100644 index 00000000000..db4fb4959cf --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class U, class... Args> +// void optional<T>::emplace(initializer_list<U> il, Args&&... args); + +#include <optional> +#include <type_traits> +#include <cassert> +#include <vector> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; + int j_ = 0; +public: + static bool dtor_called; + constexpr X() : i_(0) {} + constexpr X(int i) : i_(i) {} + constexpr X(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {} + ~X() {dtor_called = true;} + + friend constexpr bool operator==(const X& x, const X& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +bool X::dtor_called = false; + +class Y +{ + int i_; + int j_ = 0; +public: + constexpr Y() : i_(0) {} + constexpr Y(int i) : i_(i) {} + constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {} + + friend constexpr bool operator==(const Y& x, const Y& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Z +{ + int i_; + int j_ = 0; +public: + static bool dtor_called; + constexpr Z() : i_(0) {} + constexpr Z(int i) : i_(i) {} + constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) + {throw 6;} + ~Z() {dtor_called = true;} + + friend constexpr bool operator==(const Z& x, const Z& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +bool Z::dtor_called = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + X x; + { + std::optional<X> opt(x); + assert(X::dtor_called == false); + opt.emplace({1, 2}); + assert(X::dtor_called == true); + assert(*opt == X({1, 2})); + } + } + { + std::optional<std::vector<int>> opt; + opt.emplace({1, 2, 3}, std::allocator<int>()); + assert(static_cast<bool>(opt) == true); + assert(*opt == std::vector<int>({1, 2, 3})); + } + { + std::optional<Y> opt; + opt.emplace({1, 2}); + assert(static_cast<bool>(opt) == true); + assert(*opt == Y({1, 2})); + } + { + Z z; + std::optional<Z> opt(z); + try + { + assert(static_cast<bool>(opt) == true); + assert(Z::dtor_called == false); + opt.emplace({1, 2}); + } + catch (int i) + { + assert(i == 6); + assert(static_cast<bool>(opt) == false); + assert(Z::dtor_called == true); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp new file mode 100644 index 00000000000..a1574d6bb62 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// optional<T>& operator=(optional<T>&& rhs) +// noexcept(is_nothrow_move_assignable<T>::value && +// is_nothrow_move_constructible<T>::value); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + static bool throw_now; + + X() = default; + X(X&&) + { + if (throw_now) + throw 6; + } + X& operator=(X&&) noexcept + { + return *this; + } +}; + +struct Y {}; + +bool X::throw_now = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + static_assert(std::is_nothrow_move_assignable<std::optional<int>>::value, ""); + std::optional<int> opt; + constexpr std::optional<int> opt2; + opt = std::move(opt2); + static_assert(static_cast<bool>(opt2) == false, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + } + { + std::optional<int> opt; + constexpr std::optional<int> opt2(2); + opt = std::move(opt2); + static_assert(static_cast<bool>(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + assert(*opt == *opt2); + } + { + std::optional<int> opt(3); + constexpr std::optional<int> opt2; + opt = std::move(opt2); + static_assert(static_cast<bool>(opt2) == false, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + } + { + std::optional<int> opt(3); + constexpr std::optional<int> opt2(2); + opt = std::move(opt2); + static_assert(static_cast<bool>(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); + assert(*opt == *opt2); + } + { + static_assert(!std::is_nothrow_move_assignable<std::optional<X>>::value, ""); + std::optional<X> opt; + std::optional<X> opt2(X{}); + assert(static_cast<bool>(opt2) == true); + try + { + X::throw_now = true; + opt = std::move(opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + assert(static_cast<bool>(opt) == false); + } + } + { + static_assert(std::is_nothrow_move_assignable<std::optional<Y>>::value, ""); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp new file mode 100644 index 00000000000..2c87fe9b1ec --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// optional<T>& operator=(nullopt_t) noexcept; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + static bool dtor_called; + ~X() {dtor_called = true;} +}; + +bool X::dtor_called = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt; + static_assert(noexcept(opt = std::nullopt) == true, ""); + opt = std::nullopt; + assert(static_cast<bool>(opt) == false); + } + { + std::optional<int> opt(3); + opt = std::nullopt; + assert(static_cast<bool>(opt) == false); + } + { + std::optional<X> opt; + static_assert(noexcept(opt = std::nullopt) == true, ""); + assert(X::dtor_called == false); + opt = std::nullopt; + assert(X::dtor_called == false); + assert(static_cast<bool>(opt) == false); + } + { + X x; + { + std::optional<X> opt(x); + assert(X::dtor_called == false); + opt = std::nullopt; + assert(X::dtor_called == true); + assert(static_cast<bool>(opt) == false); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp new file mode 100644 index 00000000000..2e69b30580a --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp @@ -0,0 +1,115 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr optional(const T& v); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; +public: + X(int i) : i_(i) {} + + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +class Y +{ + int i_; +public: + constexpr Y(int i) : i_(i) {} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} +}; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(const Z&) {throw 6;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + constexpr T t(5); + constexpr std::optional<T> opt(t); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef double T; + constexpr T t(3); + constexpr std::optional<T> opt(t); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef X T; + const T t(3); + std::optional<T> opt(t); + assert(static_cast<bool>(opt) == true); + assert(*opt == 3); + } + { + typedef Y T; + constexpr T t(3); + constexpr std::optional<T> opt(t); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef Z T; + try + { + const T t(3); + std::optional<T> opt(t); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp new file mode 100644 index 00000000000..84319ad15ea --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -0,0 +1,122 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// optional(const optional<T>& rhs); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +template <class T> +void +test(const std::optional<T>& rhs, bool is_going_to_throw = false) +{ + bool rhs_engaged = static_cast<bool>(rhs); + try + { + std::optional<T> lhs = rhs; + assert(is_going_to_throw == false); + assert(static_cast<bool>(lhs) == rhs_engaged); + if (rhs_engaged) + assert(*lhs == *rhs); + } + catch (int i) + { + assert(i == 6); + } +} + +class X +{ + int i_; +public: + X(int i) : i_(i) {} + X(const X& x) : i_(x.i_) {} + ~X() {i_ = 0;} + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +class Y +{ + int i_; +public: + Y(int i) : i_(i) {} + Y(const Y& x) : i_(x.i_) {} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} +}; + +int count = 0; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(const Z&) + { + if (++count == 2) + throw 6; + } + + friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + std::optional<T> rhs; + test(rhs); + } + { + typedef int T; + std::optional<T> rhs(3); + test(rhs); + } + { + typedef X T; + std::optional<T> rhs; + test(rhs); + } + { + typedef X T; + std::optional<T> rhs(X(3)); + test(rhs); + } + { + typedef Y T; + std::optional<T> rhs; + test(rhs); + } + { + typedef Y T; + std::optional<T> rhs(Y(3)); + test(rhs); + } + { + typedef Z T; + std::optional<T> rhs; + test(rhs); + } + { + typedef Z T; + std::optional<T> rhs(Z(3)); + test(rhs, true); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp new file mode 100644 index 00000000000..5f9c5af5a29 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr optional() noexcept; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +template <class Opt> +void +test_constexpr() +{ + static_assert(std::is_nothrow_default_constructible<Opt>::value, ""); + constexpr Opt opt; + static_assert(static_cast<bool>(opt) == false, ""); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; + +} + +template <class Opt> +void +test() +{ + static_assert(std::is_nothrow_default_constructible<Opt>::value, ""); + Opt opt; + assert(static_cast<bool>(opt) == false); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; +} + +struct X +{ + X(); +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + test_constexpr<std::optional<int>>(); + test_constexpr<std::optional<int*>>(); + test<std::optional<X>>(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp new file mode 100644 index 00000000000..db1b62970b2 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp @@ -0,0 +1,141 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class... Args> +// constexpr explicit optional(in_place_t, Args&&... args); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; + int j_ = 0; +public: + X() : i_(0) {} + X(int i) : i_(i) {} + X(int i, int j) : i_(i), j_(j) {} + + ~X() {} + + friend bool operator==(const X& x, const X& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Y +{ + int i_; + int j_ = 0; +public: + constexpr Y() : i_(0) {} + constexpr Y(int i) : i_(i) {} + constexpr Y(int i, int j) : i_(i), j_(j) {} + + friend constexpr bool operator==(const Y& x, const Y& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {throw 6;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<int> opt(std::in_place, 5); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public std::optional<int> + { + constexpr test_constexpr_ctor(std::in_place_t, int i) + : std::optional<int>(std::in_place, i) {} + }; + + } + { + const std::optional<X> opt(std::in_place); + assert(static_cast<bool>(opt) == true); + assert(*opt == X()); + } + { + const std::optional<X> opt(std::in_place, 5); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(5)); + } + { + const std::optional<X> opt(std::in_place, 5, 4); + assert(static_cast<bool>(opt) == true); + assert(*opt == X(5, 4)); + } + { + constexpr std::optional<Y> opt(std::in_place); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == Y(), ""); + + struct test_constexpr_ctor + : public std::optional<Y> + { + constexpr test_constexpr_ctor(std::in_place_t) + : std::optional<Y>(std::in_place) {} + }; + + } + { + constexpr std::optional<Y> opt(std::in_place, 5); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == Y(5), ""); + + struct test_constexpr_ctor + : public std::optional<Y> + { + constexpr test_constexpr_ctor(std::in_place_t, int i) + : std::optional<Y>(std::in_place, i) {} + }; + + } + { + constexpr std::optional<Y> opt(std::in_place, 5, 4); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == Y(5, 4), ""); + + struct test_constexpr_ctor + : public std::optional<Y> + { + constexpr test_constexpr_ctor(std::in_place_t, int i, int j) + : std::optional<Y>(std::in_place, i, j) {} + }; + + } + { + try + { + const std::optional<Z> opt(std::in_place, 1); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp new file mode 100644 index 00000000000..076554a407d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp @@ -0,0 +1,122 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class U, class... Args> +// constexpr +// explicit optional(in_place_t, initializer_list<U> il, Args&&... args); + +#include <optional> +#include <type_traits> +#include <vector> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; + int j_ = 0; +public: + X() : i_(0) {} + X(int i) : i_(i) {} + X(int i, int j) : i_(i), j_(j) {} + + ~X() {} + + friend bool operator==(const X& x, const X& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Y +{ + int i_; + int j_ = 0; +public: + constexpr Y() : i_(0) {} + constexpr Y(int i) : i_(i) {} + constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {} + + friend constexpr bool operator==(const Y& x, const Y& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + +class Z +{ + int i_; + int j_ = 0; +public: + constexpr Z() : i_(0) {} + constexpr Z(int i) : i_(i) {} + constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) + {throw 6;} + + friend constexpr bool operator==(const Z& x, const Z& y) + {return x.i_ == y.i_ && x.j_ == y.j_;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + static_assert(!std::is_constructible<X, std::initializer_list<int>&>::value, ""); + static_assert(!std::is_constructible<std::optional<X>, std::initializer_list<int>&>::value, ""); + } + { + std::optional<std::vector<int>> opt(std::in_place, {3, 1}); + assert(static_cast<bool>(opt) == true); + assert((*opt == std::vector<int>{3, 1})); + assert(opt->size() == 2); + } + { + std::optional<std::vector<int>> opt(std::in_place, {3, 1}, std::allocator<int>()); + assert(static_cast<bool>(opt) == true); + assert((*opt == std::vector<int>{3, 1})); + assert(opt->size() == 2); + } + { + static_assert(std::is_constructible<std::optional<Y>, std::initializer_list<int>&>::value, ""); + constexpr std::optional<Y> opt(std::in_place, {3, 1}); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == Y{3, 1}, ""); + + struct test_constexpr_ctor + : public std::optional<Y> + { + constexpr test_constexpr_ctor(std::in_place_t, std::initializer_list<int> i) + : std::optional<Y>(std::in_place, i) {} + }; + + } + { + static_assert(std::is_constructible<std::optional<Z>, std::initializer_list<int>&>::value, ""); + try + { + std::optional<Z> opt(std::in_place, {3, 1}); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + + struct test_constexpr_ctor + : public std::optional<Z> + { + constexpr test_constexpr_ctor(std::in_place_t, std::initializer_list<int> i) + : std::optional<Z>(std::in_place, i) {} + }; + + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp new file mode 100644 index 00000000000..70004fd8655 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -0,0 +1,122 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +template <class T> +void +test(std::optional<T>& rhs, bool is_going_to_throw = false) +{ + static_assert(std::is_nothrow_move_constructible<std::optional<T>>::value == + std::is_nothrow_move_constructible<T>::value, ""); + bool rhs_engaged = static_cast<bool>(rhs); + try + { + std::optional<T> lhs = std::move(rhs); + assert(is_going_to_throw == false); + assert(static_cast<bool>(lhs) == rhs_engaged); + } + catch (int i) + { + assert(i == 6); + } +} + +class X +{ + int i_; +public: + X(int i) : i_(i) {} + X(X&& x) : i_(x.i_) {x.i_ = 0;} + ~X() {i_ = 0;} + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +class Y +{ + int i_; +public: + Y(int i) : i_(i) {} + Y(Y&& x) noexcept : i_(x.i_) {x.i_ = 0;} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} +}; + +int count = 0; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(Z&&) + { + if (++count == 2) + throw 6; + } + + friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + std::optional<T> rhs; + test(rhs); + } + { + typedef int T; + std::optional<T> rhs(3); + test(rhs); + } + { + typedef X T; + std::optional<T> rhs; + test(rhs); + } + { + typedef X T; + std::optional<T> rhs(X(3)); + test(rhs); + } + { + typedef Y T; + std::optional<T> rhs; + test(rhs); + } + { + typedef Y T; + std::optional<T> rhs(Y(3)); + test(rhs); + } + { + typedef Z T; + std::optional<T> rhs; + test(rhs); + } + { + typedef Z T; + std::optional<T> rhs(Z(3)); + test(rhs, true); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp new file mode 100644 index 00000000000..0d0f1e9a216 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr optional(nullopt_t) noexcept; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +template <class Opt> +void +test_constexpr() +{ + static_assert(noexcept(Opt(std::nullopt)), ""); + constexpr Opt opt(std::nullopt); + static_assert(static_cast<bool>(opt) == false, ""); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; +} + +template <class Opt> +void +test() +{ + static_assert(noexcept(Opt(std::nullopt)), ""); + Opt opt(std::nullopt); + assert(static_cast<bool>(opt) == false); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; +} + +struct X +{ + X(); +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + test_constexpr<std::optional<int>>(); + test_constexpr<std::optional<int*>>(); + test<std::optional<X>>(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp new file mode 100644 index 00000000000..c07dd634398 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr optional(T&& v); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; +public: + X(int i) : i_(i) {} + X(X&& x) : i_(x.i_) {} + + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +class Y +{ + int i_; +public: + constexpr Y(int i) : i_(i) {} + constexpr Y(Y&& x) : i_(x.i_) {} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} +}; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(Z&&) {throw 6;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + constexpr std::optional<T> opt(T(5)); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef double T; + constexpr std::optional<T> opt(T(3)); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef X T; + std::optional<T> opt(T(3)); + assert(static_cast<bool>(opt) == true); + assert(*opt == 3); + } + { + typedef Y T; + constexpr std::optional<T> opt(T(3)); + static_assert(static_cast<bool>(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public std::optional<T> + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef Z T; + try + { + std::optional<T> opt(T(3)); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp new file mode 100644 index 00000000000..428e6743618 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// ~optional(); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ +public: + static bool dtor_called; + X() = default; + ~X() {dtor_called = true;} +}; + +bool X::dtor_called = false; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + static_assert(std::is_trivially_destructible<T>::value, ""); + static_assert(std::is_trivially_destructible<std::optional<T>>::value, ""); + } + { + typedef double T; + static_assert(std::is_trivially_destructible<T>::value, ""); + static_assert(std::is_trivially_destructible<std::optional<T>>::value, ""); + } + { + typedef X T; + static_assert(!std::is_trivially_destructible<T>::value, ""); + static_assert(!std::is_trivially_destructible<std::optional<T>>::value, ""); + { + X x; + std::optional<X> opt{x}; + assert(X::dtor_called == false); + } + assert(X::dtor_called == true); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp new file mode 100644 index 00000000000..657af2c5dad --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr explicit optional<T>::operator bool() const noexcept; + +#include <optional> +#include <type_traits> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<int> opt; + static_assert(!opt, ""); + } + { + constexpr std::optional<int> opt(0); + static_assert(opt, ""); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp new file mode 100644 index 00000000000..5ef4245feb9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T& optional<T>::operator*(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + constexpr int test() const {return 3;} + int test() {return 4;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<X> opt(X{}); + assert((*opt).test() == 4); + } +#ifdef _LIBCPP_DEBUG + { + std::optional<X> opt; + assert((*opt).test() == 3); + assert(false); + } +#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp new file mode 100644 index 00000000000..6ea5e118857 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr const T& optional<T>::operator*() const; + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + constexpr int test() const {return 3;} +}; + +struct Y +{ + int test() const {return 2;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<X> opt(X{}); + static_assert((*opt).test() == 3, ""); + } + { + constexpr std::optional<Y> opt(Y{}); + assert((*opt).test() == 2); + } +#ifdef _LIBCPP_DEBUG + { + const std::optional<X> opt; + assert((*opt).test() == 3); + assert(false); + } +#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp new file mode 100644 index 00000000000..54c19e716e9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T* optional<T>::operator->(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int test() const {return 2;} + int test() {return 3;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<X> opt(X{}); + assert(opt->test() == 3); + } +#ifdef _LIBCPP_DEBUG + { + std::optional<X> opt; + assert(opt->test() == 3); + assert(false); + } +#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp new file mode 100644 index 00000000000..94f62e29baa --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr const T* optional<T>::operator->() const; + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + constexpr int test() const {return 3;} +}; + +struct Y +{ + int test() const {return 2;} +}; + +struct Z +{ + const Z* operator&() const {return this;} + constexpr int test() const {return 1;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<X> opt(X{}); + static_assert(opt->test() == 3, ""); + } + { + constexpr std::optional<Y> opt(Y{}); + assert(opt->test() == 2); + } + { + constexpr std::optional<Z> opt(Z{}); + assert(opt->test() == 1); + } +#ifdef _LIBCPP_DEBUG + { + const std::optional<X> opt; + assert(opt->test() == 3); + assert(false); + } +#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp new file mode 100644 index 00000000000..245070c6c82 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T& optional<T>::value(); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + X() = default; + X(const X&) = delete; + constexpr int test() const {return 3;} + int test() {return 4;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<X> opt; + opt.emplace(); + assert(opt.value().test() == 4); + } + { + std::optional<X> opt; + try + { + opt.value(); + assert(false); + } + catch (const std::bad_optional_access&) + { + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp new file mode 100644 index 00000000000..f22220c3e9d --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr const T& optional<T>::value() const; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + constexpr int test() const {return 3;} + int test() {return 4;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<X> opt; + static_assert(opt.value().test() == 3, ""); + } +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp new file mode 100644 index 00000000000..1c6776524b4 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// constexpr const T& optional<T>::value() const; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + X() = default; + X(const X&) = delete; + constexpr int test() const {return 3;} + int test() {return 4;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<X> opt(std::in_place); + static_assert(opt.value().test() == 3, ""); + } + { + const std::optional<X> opt(std::in_place); + assert(opt.value().test() == 3); + } + { + const std::optional<X> opt; + try + { + opt.value(); + assert(false); + } + catch (const std::bad_optional_access&) + { + } + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp new file mode 100644 index 00000000000..52a3f5d4dd6 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class U> T optional<T>::value_or(U&& v) &&; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct Y +{ + int i_; + + Y(int i) : i_(i) {} +}; + +struct X +{ + int i_; + + X(int i) : i_(i) {} + X(X&& x) : i_(x.i_) {x.i_ = 0;} + X(const Y& y) : i_(y.i_) {} + X(Y&& y) : i_(y.i_+1) {} + friend constexpr bool operator==(const X& x, const X& y) + {return x.i_ == y.i_;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<X> opt(std::in_place, 2); + Y y(3); + assert(std::move(opt).value_or(y) == 2); + assert(*opt == 0); + } + { + std::optional<X> opt(std::in_place, 2); + assert(std::move(opt).value_or(Y(3)) == 2); + assert(*opt == 0); + } + { + std::optional<X> opt; + Y y(3); + assert(std::move(opt).value_or(y) == 3); + assert(!opt); + } + { + std::optional<X> opt; + assert(std::move(opt).value_or(Y(3)) == 4); + assert(!opt); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp new file mode 100644 index 00000000000..e95ab2d25df --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class U> constexpr T optional<T>::value_or(U&& v) const&; + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct Y +{ + int i_; + + constexpr Y(int i) : i_(i) {} +}; + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} + constexpr X(const Y& y) : i_(y.i_) {} + constexpr X(Y&& y) : i_(y.i_+1) {} + friend constexpr bool operator==(const X& x, const X& y) + {return x.i_ == y.i_;} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::optional<X> opt(2); + constexpr Y y(3); + static_assert(opt.value_or(y) == 2, ""); + } + { + constexpr std::optional<X> opt(2); + static_assert(opt.value_or(Y(3)) == 2, ""); + } + { + constexpr std::optional<X> opt; + constexpr Y y(3); + static_assert(opt.value_or(y) == 3, ""); + } + { + constexpr std::optional<X> opt; + static_assert(opt.value_or(Y(3)) == 4, ""); + } + { + const std::optional<X> opt(2); + const Y y(3); + assert(opt.value_or(y) == 2); + } + { + const std::optional<X> opt(2); + assert(opt.value_or(Y(3)) == 2); + } + { + const std::optional<X> opt; + const Y y(3); + assert(opt.value_or(y) == 3); + } + { + const std::optional<X> opt; + assert(opt.value_or(Y(3)) == 4); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp new file mode 100644 index 00000000000..5672332bb51 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp @@ -0,0 +1,304 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// void swap(optional&) +// noexcept(is_nothrow_move_constructible<T>::value && +// noexcept(swap(declval<T&>(), declval<T&>()))); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; +public: + static unsigned dtor_called; + X(int i) : i_(i) {} + X(X&& x) = default; + X& operator=(X&&) = default; + ~X() {++dtor_called;} + + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +unsigned X::dtor_called = 0; + +class Y +{ + int i_; +public: + static unsigned dtor_called; + Y(int i) : i_(i) {} + Y(Y&&) = default; + ~Y() {++dtor_called;} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} + friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);} +}; + +unsigned Y::dtor_called = 0; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(Z&&) {throw 7;} + + friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} + friend void swap(Z& x, Z& y) {throw 6;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt1; + std::optional<int> opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<int> opt1(1); + std::optional<int> opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<int> opt1; + std::optional<int> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<int> opt1(1); + std::optional<int> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<X> opt1; + std::optional<X> opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + assert(X::dtor_called == 0); + } + { + std::optional<X> opt1(1); + std::optional<X> opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<X> opt1; + std::optional<X> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<X> opt1(1); + std::optional<X> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); // from inside std::swap + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Y> opt1; + std::optional<Y> opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + assert(Y::dtor_called == 0); + } + { + std::optional<Y> opt1(1); + std::optional<Y> opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 1); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Y> opt1; + std::optional<Y> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 1); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Y> opt1(1); + std::optional<Y> opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 0); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Z> opt1; + std::optional<Z> opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + opt1.swap(opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Z> opt1; + opt1.emplace(1); + std::optional<Z> opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Z> opt1; + std::optional<Z> opt2; + opt2.emplace(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + } + { + std::optional<Z> opt1; + opt1.emplace(1); + std::optional<Z> opt2; + opt2.emplace(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_const_void.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_const_void.fail.cpp new file mode 100644 index 00000000000..a471fb55eb6 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_const_void.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<const void> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp new file mode 100644 index 00000000000..19b037e1446 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include <optional> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ +private: + ~X() {} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<X> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp new file mode 100644 index 00000000000..da4d8c1ed60 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include <optional> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + ~X() noexcept(false) {} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<X> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_void.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_void.fail.cpp new file mode 100644 index 00000000000..950043a26bb --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/optional_void.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<void> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/types.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/types.pass.cpp new file mode 100644 index 00000000000..ae3f7d7d3d9 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.object/types.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> +// class optional +// { +// public: +// typedef T value_type; +// ... + +#include <optional> +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +template <class Opt, class T> +void +test() +{ + static_assert(std::is_same<typename Opt::value_type, T>::value, ""); +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + test<std::optional<int>, int>(); + test<std::optional<const int>, const int>(); + test<std::optional<double>, double>(); + test<std::optional<const double>, const double>(); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/equal.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/equal.pass.cpp new file mode 100644 index 00000000000..3bbbb4e58b4 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/equal.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> constexpr bool operator==(const optional<T>& x, const optional<T>& y); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} +}; + +constexpr bool operator == ( const X &lhs, const X &rhs ) + { return lhs.i_ == rhs.i_ ; } + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef X T; + typedef std::optional<T> O; + + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged + + static_assert ( o1 == o1 , "" ); + static_assert ( o1 == o2 , "" ); + static_assert ( !(o1 == o3), "" ); + static_assert ( !(o1 == o4), "" ); + static_assert ( !(o1 == o5), "" ); + + static_assert ( o2 == o1 , "" ); + static_assert ( o2 == o2 , "" ); + static_assert ( !(o2 == o3), "" ); + static_assert ( !(o2 == o4), "" ); + static_assert ( !(o2 == o5), "" ); + + static_assert ( !(o3 == o1), "" ); + static_assert ( !(o3 == o2), "" ); + static_assert ( o3 == o3 , "" ); + static_assert ( !(o3 == o4), "" ); + static_assert ( o3 == o5 , "" ); + + static_assert ( !(o4 == o1), "" ); + static_assert ( !(o4 == o2), "" ); + static_assert ( !(o4 == o3), "" ); + static_assert ( o4 == o4 , "" ); + static_assert ( !(o4 == o5), "" ); + + static_assert ( !(o5 == o1), "" ); + static_assert ( !(o5 == o2), "" ); + static_assert ( o5 == o3 , "" ); + static_assert ( !(o5 == o4), "" ); + static_assert ( o5 == o5 , "" ); + + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp new file mode 100644 index 00000000000..515ca9caea7 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> constexpr bool operator< (const optional<T>& x, const optional<T>& y); + +#include <optional> + +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} +}; + +constexpr bool operator < ( const X &lhs, const X &rhs ) + { return lhs.i_ < rhs.i_ ; } + +#endif + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef std::optional<X> O; + + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged + + static_assert ( !(o1 < o1), "" ); + static_assert ( !(o1 < o2), "" ); + static_assert ( o1 < o3 , "" ); + static_assert ( o1 < o4 , "" ); + static_assert ( o1 < o5 , "" ); + + static_assert ( !(o2 < o1), "" ); + static_assert ( !(o2 < o2), "" ); + static_assert ( o2 < o3 , "" ); + static_assert ( o2 < o4 , "" ); + static_assert ( o2 < o5 , "" ); + + static_assert ( !(o3 < o1), "" ); + static_assert ( !(o3 < o2), "" ); + static_assert ( !(o3 < o3), "" ); + static_assert ( o3 < o4 , "" ); + static_assert ( !(o3 < o5), "" ); + + static_assert ( !(o4 < o1), "" ); + static_assert ( !(o4 < o2), "" ); + static_assert ( !(o4 < o3), "" ); + static_assert ( !(o4 < o4), "" ); + static_assert ( !(o4 < o5), "" ); + + static_assert ( !(o5 < o1), "" ); + static_assert ( !(o5 < o2), "" ); + static_assert ( !(o5 < o3), "" ); + static_assert ( o5 < o4 , "" ); + static_assert ( !(o5 < o5), "" ); + } +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/make_optional.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/make_optional.pass.cpp new file mode 100644 index 00000000000..afd735a634b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/make_optional.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> +// constexpr +// optional<typename decay<T>::type> +// make_optional(T&& v); + +#include <optional> +#include <string> +#include <memory> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt = std::make_optional(2); + assert(*opt == 2); + } + { + std::string s("123"); + std::optional<std::string> opt = std::make_optional(s); + assert(*opt == s); + } + { + std::string s("123"); + std::optional<std::string> opt = std::make_optional(std::move(s)); + assert(*opt == "123"); + assert(s.empty()); + } + { + std::unique_ptr<int> s(new int(3)); + std::optional<std::unique_ptr<int>> opt = std::make_optional(std::move(s)); + assert(**opt == 3); + assert(s == nullptr); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/swap.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/swap.pass.cpp new file mode 100644 index 00000000000..d98dd40ec6b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.specalg/swap.pass.cpp @@ -0,0 +1,303 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// template <class T> void swap(optional<T>& x, optional<T>& y) +// noexcept(noexcept(x.swap(y))); + +#include <optional> +#include <type_traits> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class X +{ + int i_; +public: + static unsigned dtor_called; + X(int i) : i_(i) {} + X(X&& x) = default; + X& operator=(X&&) = default; + ~X() {++dtor_called;} + + friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} +}; + +unsigned X::dtor_called = 0; + +class Y +{ + int i_; +public: + static unsigned dtor_called; + Y(int i) : i_(i) {} + Y(Y&&) = default; + ~Y() {++dtor_called;} + + friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;} + friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);} +}; + +unsigned Y::dtor_called = 0; + +class Z +{ + int i_; +public: + Z(int i) : i_(i) {} + Z(Z&&) {throw 7;} + + friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} + friend void swap(Z& x, Z& y) {throw 6;} +}; + + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::optional<int> opt1; + std::optional<int> opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<int> opt1(1); + std::optional<int> opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<int> opt1; + std::optional<int> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<int> opt1(1); + std::optional<int> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<X> opt1; + std::optional<X> opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + assert(X::dtor_called == 0); + } + { + std::optional<X> opt1(1); + std::optional<X> opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<X> opt1; + std::optional<X> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<X> opt1(1); + std::optional<X> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); // from inside std::swap + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Y> opt1; + std::optional<Y> opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + assert(Y::dtor_called == 0); + } + { + std::optional<Y> opt1(1); + std::optional<Y> opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 1); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Y> opt1; + std::optional<Y> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 1); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Y> opt1(1); + std::optional<Y> opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 0); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 2); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 1); + } + { + std::optional<Z> opt1; + std::optional<Z> opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + swap(opt1, opt2); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Z> opt1; + opt1.emplace(1); + std::optional<Z> opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == false); + } + { + std::optional<Z> opt1; + std::optional<Z> opt2; + opt2.emplace(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast<bool>(opt1) == false); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + } + { + std::optional<Z> opt1; + opt1.emplace(1); + std::optional<Z> opt2; + opt2.emplace(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + assert(static_cast<bool>(opt1) == true); + assert(*opt1 == 1); + assert(static_cast<bool>(opt2) == true); + assert(*opt2 == 2); + } +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp new file mode 100644 index 00000000000..fc661f0eadc --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) in_place_t is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<const std::inplace_t> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp new file mode 100644 index 00000000000..8836ee6716c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<const int&> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp new file mode 100644 index 00000000000..82aa4c1220c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) null_opt_t is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<const std::nullopt_t> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp new file mode 100644 index 00000000000..eb11460157b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) in_place_t is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<std::inplace_t> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp new file mode 100644 index 00000000000..df5d246cef6 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// #include <initializer_list> + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::initializer_list<int> list; +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp new file mode 100644 index 00000000000..bc143fc6c13 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<int&> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp new file mode 100644 index 00000000000..bcb152e553c --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) null_opt_t is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<std::nullopt_t> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp new file mode 100644 index 00000000000..a0ba2f00699 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include <optional> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::optional<int&&> opt; +#else +#error +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/optional/version.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/optional/version.pass.cpp new file mode 100644 index 00000000000..e7581b5431b --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/optional/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <optional> + +#include <optional> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp new file mode 100644 index 00000000000..74b65d6b9cc --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +// duration + +// template <class Rep2, class Period2> +// duration(const duration<Rep2, Period2>& d); + +// overflow should SFINAE instead of error out, LWG 2094 + +#include <chrono> +#include <cassert> + +bool called = false; + +void f(std::chrono::milliseconds); +void f(std::chrono::seconds) +{ + called = true; +} + +int main() +{ + { + std::chrono::duration<int, std::exa> r(1); + f(r); + assert(called); + } +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp new file mode 100644 index 00000000000..46aaa30e51e --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp @@ -0,0 +1,21 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#include <chrono> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::chrono::hours h = 4h; // should fail w/conversion operator not found +#else +#error +#endif +} + diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp new file mode 100644 index 00000000000..574f9bcce87 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp @@ -0,0 +1,48 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#include <chrono> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::chrono; + + hours h = 4h; + assert ( h == hours(4)); + auto h2 = 4.0h; + assert ( h == h2 ); + + minutes min = 36min; + assert ( min == minutes(36)); + auto min2 = 36.0min; + assert ( min == min2 ); + + seconds s = 24s; + assert ( s == seconds(24)); + auto s2 = 24.0s; + assert ( s == s2 ); + + milliseconds ms = 247ms; + assert ( ms == milliseconds(247)); + auto ms2 = 247.0ms; + assert ( ms == ms2 ); + + microseconds us = 867us; + assert ( us == microseconds(867)); + auto us2 = 867.0us; + assert ( us == us2 ); + + nanoseconds ns = 645ns; + assert ( ns == nanoseconds(645)); + auto ns2 = 645.ns; + assert ( ns == ns2 ); +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp new file mode 100644 index 00000000000..17358e589f4 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp @@ -0,0 +1,22 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#include <chrono> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::chrono::hours; + + hours foo = 4h; // should fail w/conversion operator not found +#else +#error +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp new file mode 100644 index 00000000000..e37bc6e6796 --- /dev/null +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +#include <chrono> +#include <type_traits> +#include <cassert> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals; + + std::chrono::hours h = 4h; + assert ( h == std::chrono::hours(4)); + auto h2 = 4.0h; + assert ( h == h2 ); + + std::chrono::minutes min = 36min; + assert ( min == std::chrono::minutes(36)); + auto min2 = 36.0min; + assert ( min == min2 ); + + std::chrono::seconds s = 24s; + assert ( s == std::chrono::seconds(24)); + auto s2 = 24.0s; + assert ( s == s2 ); + + std::chrono::milliseconds ms = 247ms; + assert ( ms == std::chrono::milliseconds(247)); + auto ms2 = 247.0ms; + assert ( ms == ms2 ); + + std::chrono::microseconds us = 867us; + assert ( us == std::chrono::microseconds(867)); + auto us2 = 867.0us; + assert ( us == us2 ); + + std::chrono::nanoseconds ns = 645ns; + assert ( ns == std::chrono::nanoseconds(645)); + auto ns2 = 645.ns; + assert ( ns == ns2 ); +#endif +} diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp index 04b43672c61..7d7e82ac5e2 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp @@ -35,6 +35,8 @@ test(const FromDuration& df, const ToDuration& d) } } +#if _LIBCPP_STD_VER > 11 + template<class FromDuration, long long From, class ToDuration, long long To> void test_constexpr () { @@ -49,6 +51,8 @@ void test_constexpr () } +#endif + int main() { test(std::chrono::milliseconds(7265000), std::chrono::hours(2)); diff --git a/external/bsd/libc++/dist/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp b/external/bsd/libc++/dist/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp index 148850ee0d6..5e84ff8e882 100644 --- a/external/bsd/libc++/dist/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp +++ b/external/bsd/libc++/dist/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp @@ -51,6 +51,15 @@ test2a(const Tuple& t) assert(std::get<1>(t) == 'a'); } +#if _LIBCPP_STD_VER > 11 +template <class Tuple> +constexpr int +test3(const Tuple& t) +{ + return std::tuple_size<Tuple>::value; +} +#endif + int main() { { @@ -67,5 +76,8 @@ int main() double i = 2.5; char c = 'a'; test2a(std::forward_as_tuple(i, c)); +#if _LIBCPP_STD_VER > 11 + static_assert ( test3 (std::forward_as_tuple(i, c)) == 2, "" ); +#endif } } |
