diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/__config | 9 | ||||
| -rw-r--r-- | include/__string | 12 | ||||
| -rw-r--r-- | include/__threading_support | 22 | ||||
| -rw-r--r-- | include/deque | 23 | ||||
| -rw-r--r-- | include/forward_list | 12 | ||||
| -rw-r--r-- | include/list | 28 | ||||
| -rw-r--r-- | include/queue | 7 | ||||
| -rw-r--r-- | include/stack | 7 | ||||
| -rw-r--r-- | include/vector | 23 |
9 files changed, 110 insertions, 33 deletions
diff --git a/include/__config b/include/__config index ddfab31f7fac..340c573a2a40 100644 --- a/include/__config +++ b/include/__config @@ -403,15 +403,6 @@ namespace std { #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif -// A constexpr version of __builtin_memcmp was added in clang 4.0 -#if __has_builtin(__builtin_memcmp) -# ifdef __apple_build_version__ -// No shipping version of Apple's clang has constexpr __builtin_memcmp -# elif __clang_major__ > 3 -# define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR -# endif -#endif - #elif defined(_LIBCPP_COMPILER_GCC) #define _ALIGNAS(x) __attribute__((__aligned__(x))) diff --git a/include/__string b/include/__string index c85b874f054b..75608cea71d9 100644 --- a/include/__string +++ b/include/__string @@ -243,7 +243,7 @@ char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t { if (__n == 0) return 0; -#ifdef _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_memcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 return memcmp(__s1, __s2, __n); @@ -265,7 +265,9 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) { if (__n == 0) return NULL; -#if _LIBCPP_STD_VER <= 14 +#if __has_feature(cxx_constexpr_string_builtins) + return __builtin_char_memchr(__s, to_int_type(__a), __n); +#elif _LIBCPP_STD_VER <= 14 return (const char_type*) memchr(__s, to_int_type(__a), __n); #else for (; __n; --__n) @@ -331,7 +333,7 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size { if (__n == 0) return 0; -#if __has_builtin(__builtin_wmemcmp) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 return wmemcmp(__s1, __s2, __n); @@ -351,7 +353,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT { -#if __has_builtin(__builtin_wcslen) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wcslen(__s); #elif _LIBCPP_STD_VER <= 14 return wcslen(__s); @@ -369,7 +371,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __ { if (__n == 0) return NULL; -#if __has_builtin(__builtin_wmemchr) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemchr(__s, __a, __n); #elif _LIBCPP_STD_VER <= 14 return wmemchr(__s, __a, __n); diff --git a/include/__threading_support b/include/__threading_support index a672a9f80eda..817a2cfb934f 100644 --- a/include/__threading_support +++ b/include/__threading_support @@ -40,6 +40,12 @@ #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY #endif +#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) +#else +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS +#endif + _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) @@ -98,25 +104,25 @@ typedef DWORD __libcpp_tls_key; _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_trylock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY @@ -129,10 +135,10 @@ int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts); diff --git a/include/deque b/include/deque index 0454162a8f73..92801540f2e7 100644 --- a/include/deque +++ b/include/deque @@ -110,8 +110,8 @@ public: void push_front(value_type&& v); void push_back(const value_type& v); void push_back(value_type&& v); - template <class... Args> reference emplace_front(Args&&... args); - template <class... Args> reference emplace_back(Args&&... args); + template <class... Args> reference emplace_front(Args&&... args); // reference in C++17 + template <class... Args> reference emplace_back(Args&&... args); // reference in C++17 template <class... Args> iterator emplace(const_iterator p, Args&&... args); iterator insert(const_iterator p, const value_type& v); iterator insert(const_iterator p, value_type&& v); @@ -1342,8 +1342,13 @@ public: void push_back(const value_type& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 14 template <class... _Args> reference emplace_front(_Args&&... __args); - template <class... _Args> reference emplace_back(_Args&&... __args); + template <class... _Args> reference emplace_back (_Args&&... __args); +#else + template <class... _Args> void emplace_front(_Args&&... __args); + template <class... _Args> void emplace_back (_Args&&... __args); +#endif template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS void push_front(value_type&& __v); @@ -1822,7 +1827,11 @@ deque<_Tp, _Allocator>::push_back(value_type&& __v) template <class _Tp, class _Allocator> template <class... _Args> +#if _LIBCPP_STD_VER > 14 typename deque<_Tp, _Allocator>::reference +#else +void +#endif deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) { allocator_type& __a = __base::__alloc(); @@ -1832,7 +1841,9 @@ deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...); ++__base::size(); +#if _LIBCPP_STD_VER > 14 return *--__base::end(); +#endif } #endif // _LIBCPP_HAS_NO_VARIADICS @@ -1870,7 +1881,11 @@ deque<_Tp, _Allocator>::push_front(value_type&& __v) template <class _Tp, class _Allocator> template <class... _Args> +#if _LIBCPP_STD_VER > 14 typename deque<_Tp, _Allocator>::reference +#else +void +#endif deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { allocator_type& __a = __base::__alloc(); @@ -1880,7 +1895,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...); --__base::__start_; ++__base::size(); +#if _LIBCPP_STD_VER > 14 return *__base::begin(); +#endif } #endif // _LIBCPP_HAS_NO_VARIADICS diff --git a/include/forward_list b/include/forward_list index ce9a4b1bca90..879f2d3ce087 100644 --- a/include/forward_list +++ b/include/forward_list @@ -87,7 +87,7 @@ public: reference front(); const_reference front() const; - template <class... Args> reference emplace_front(Args&&... args); + template <class... Args> reference emplace_front(Args&&... args); // reference in C++17 void push_front(const value_type& v); void push_front(value_type&& v); @@ -747,7 +747,11 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 14 template <class... _Args> reference emplace_front(_Args&&... __args); +#else + template <class... _Args> void emplace_front(_Args&&... __args); +#endif #endif void push_front(value_type&& __v); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1103,7 +1107,11 @@ forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) template <class _Tp, class _Alloc> template <class... _Args> +#if _LIBCPP_STD_VER > 14 typename forward_list<_Tp, _Alloc>::reference +#else +void +#endif forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __node_allocator& __a = base::__alloc(); @@ -1113,7 +1121,9 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) _VSTD::forward<_Args>(__args)...); __h->__next_ = base::__before_begin()->__next_; base::__before_begin()->__next_ = __h.release(); +#if _LIBCPP_STD_VER > 14 return base::__before_begin()->__next_->__value_; +#endif } #endif // _LIBCPP_HAS_NO_VARIADICS diff --git a/include/list b/include/list index 76c50a156093..fa148db516bc 100644 --- a/include/list +++ b/include/list @@ -93,10 +93,10 @@ public: size_type max_size() const noexcept; template <class... Args> - reference emplace_front(Args&&... args); + reference emplace_front(Args&&... args); // reference in C++17 void pop_front(); template <class... Args> - reference emplace_back(Args&&... args); + reference emplace_back(Args&&... args); // reference in C++17 void pop_back(); void push_front(const value_type& x); void push_front(value_type&& x); @@ -969,9 +969,17 @@ public: void push_back(value_type&& __x); #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args> +#if _LIBCPP_STD_VER > 14 reference emplace_front(_Args&&... __args); +#else + void emplace_front(_Args&&... __args); +#endif template <class... _Args> +#if _LIBCPP_STD_VER > 14 reference emplace_back(_Args&&... __args); +#else + void emplace_back(_Args&&... __args); +#endif template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS @@ -1600,7 +1608,11 @@ list<_Tp, _Alloc>::push_back(value_type&& __x) template <class _Tp, class _Alloc> template <class... _Args> +#if _LIBCPP_STD_VER > 14 typename list<_Tp, _Alloc>::reference +#else +void +#endif list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __node_allocator& __na = base::__node_alloc(); @@ -1609,12 +1621,20 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); +#if _LIBCPP_STD_VER > 14 return __hold.release()->__value_; +#else + __hold.release(); +#endif } template <class _Tp, class _Alloc> template <class... _Args> +#if _LIBCPP_STD_VER > 14 typename list<_Tp, _Alloc>::reference +#else +void +#endif list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { __node_allocator& __na = base::__node_alloc(); @@ -1624,7 +1644,11 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) __link_pointer __nl = __hold->__as_link(); __link_nodes_at_back(__nl, __nl); ++base::__sz(); +#if _LIBCPP_STD_VER > 14 return __hold.release()->__value_; +#else + __hold.release(); +#endif } template <class _Tp, class _Alloc> diff --git a/include/queue b/include/queue index 271c203e1d24..57d420c7406c 100644 --- a/include/queue +++ b/include/queue @@ -63,7 +63,7 @@ public: void push(const value_type& v); void push(value_type&& v); - template <class... Args> reference emplace(Args&&... args); + template <class... Args> reference emplace(Args&&... args); // reference in C++17 void pop(); void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) @@ -292,8 +292,13 @@ public: #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args> _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_STD_VER > 14 reference emplace(_Args&&... __args) { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} +#else + void emplace(_Args&&... __args) + { c.emplace_back(_VSTD::forward<_Args>(__args)...);} +#endif #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY diff --git a/include/stack b/include/stack index 228864e4709b..c797ea5ec6e9 100644 --- a/include/stack +++ b/include/stack @@ -55,7 +55,7 @@ public: void push(const value_type& x); void push(value_type&& x); - template <class... Args> reference emplace(Args&&... args); + template <class... Args> reference emplace(Args&&... args); // reference in C++17 void pop(); void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) @@ -199,8 +199,13 @@ public: #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args> _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_STD_VER > 14 reference emplace(_Args&&... __args) { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} +#else + void emplace(_Args&&... __args) + { c.emplace_back(_VSTD::forward<_Args>(__args)...);} +#endif #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY diff --git a/include/vector b/include/vector index 4dd0e527ff57..ded057b10c8b 100644 --- a/include/vector +++ b/include/vector @@ -99,7 +99,7 @@ public: void push_back(const value_type& x); void push_back(value_type&& x); template <class... Args> - reference emplace_back(Args&&... args); + reference emplace_back(Args&&... args); // reference in C++17 void pop_back(); template <class... Args> iterator emplace(const_iterator position, Args&&... args); @@ -218,7 +218,7 @@ public: const_reference back() const; void push_back(const value_type& x); - template <class... Args> reference emplace_back(Args&&... args); // C++14 + template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17 void pop_back(); template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14 @@ -679,7 +679,11 @@ public: #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args> _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_STD_VER > 14 reference emplace_back(_Args&&... __args); +#else + void emplace_back(_Args&&... __args); +#endif #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY @@ -1625,7 +1629,11 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template <class _Tp, class _Allocator> template <class... _Args> inline +#if _LIBCPP_STD_VER > 14 typename vector<_Tp, _Allocator>::reference +#else +void +#endif vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { if (this->__end_ < this->__end_cap()) @@ -1639,7 +1647,9 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) } else __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...); +#if _LIBCPP_STD_VER > 14 return this->back(); +#endif } #endif // _LIBCPP_HAS_NO_VARIADICS @@ -2336,9 +2346,16 @@ public: void push_back(const value_type& __x); #if _LIBCPP_STD_VER > 11 template <class... _Args> - _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) { +#if _LIBCPP_STD_VER > 14 + _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) +#else + _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) +#endif + { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); +#if _LIBCPP_STD_VER > 14 return this->back(); +#endif } #endif |
