diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -53,63 +53,64 @@ typedef typename add_lvalue_reference::type __alloc_ref; typedef typename add_lvalue_reference::type __alloc_const_ref; - _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(__alloc_rr& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(const __alloc_rr& __a); - __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); - ~__split_buffer(); + _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer(); - __split_buffer(__split_buffer&& __c) + _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c) _NOEXCEPT_(is_nothrow_move_constructible::value); - __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); - __split_buffer& operator=(__split_buffer&& __c) + _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c) _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value) || !__alloc_traits::propagate_on_container_move_assignment::value); - _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {__destruct_at_end(__begin_);} - _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast(__end_ - __begin_);} - _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} - _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast(__end_cap() - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast(__begin_ - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast(__end_cap() - __end_);} - - _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} - _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} - - void reserve(size_type __n); - void shrink_to_fit() _NOEXCEPT; - void push_front(const_reference __x); - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); - void push_front(value_type&& __x); - void push_back(value_type&& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast(__end_ - __begin_);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast(__end_cap() - __first_);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast(__begin_ - __first_);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast(__end_cap() - __end_);} + + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} + + _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x); template - void emplace_back(_Args&&... __args); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args); - _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} - _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} - void __construct_at_end(size_type __n); - void __construct_at_end(size_type __n, const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator<_InputIter>::value && @@ -118,6 +119,7 @@ >::type __construct_at_end(_InputIter __first, _InputIter __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -125,44 +127,44 @@ >::type __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); - _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) {__destruct_at_begin(__new_begin, is_trivially_destructible());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, false_type); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, true_type); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT {__destruct_at_end(__new_last, false_type());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; - void swap(__split_buffer& __x) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| __is_nothrow_swappable<__alloc_rr>::value); - bool __invariants() const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; private: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__split_buffer& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} struct _ConstructTransaction { - explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT + _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT : __pos_(*__p), __end_(*__p + __n), __dest_(__p) { } - ~_ConstructTransaction() { + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() { *__dest_ = __pos_; } pointer __pos_; @@ -173,6 +175,7 @@ }; template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __split_buffer<_Tp, _Allocator>::__invariants() const { @@ -203,6 +206,7 @@ // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { @@ -219,6 +223,7 @@ // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -231,6 +236,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator<_InputIter>::value && @@ -259,6 +265,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -274,6 +281,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) @@ -283,6 +291,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) @@ -291,6 +300,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT @@ -300,6 +310,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT @@ -308,6 +319,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) : __end_cap_(nullptr, __a) { @@ -317,6 +329,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) @@ -325,6 +338,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) @@ -332,6 +346,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) @@ -339,6 +354,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::~__split_buffer() { clear(); @@ -347,6 +363,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) _NOEXCEPT_(is_nothrow_move_constructible::value) : __first_(_VSTD::move(__c.__first_)), @@ -361,6 +378,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) : __end_cap_(nullptr, __a) { @@ -387,6 +405,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>& __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && @@ -407,6 +426,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| @@ -420,6 +440,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::reserve(size_type __n) { @@ -436,6 +457,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { @@ -463,6 +485,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) { @@ -492,6 +515,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) { @@ -522,6 +546,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) @@ -552,6 +577,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -583,6 +609,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -613,6 +640,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -1711,7 +1711,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < is_same::type, _Up>::value && @@ -1761,7 +1761,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < is_same::type, _Up>::value && diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1064,7 +1064,6 @@ __do_it(const _Pointer &__p) _NOEXCEPT { return std::__to_address(__p.operator->()); } }; - #if _LIBCPP_STD_VER > 17 template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -1388,7 +1387,17 @@ __is_cpp17_move_insertable<_Alloc>::value> {}; - +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 +_Tp* __libcpp_memcpy(_Tp* __dest, _Tp const* __src, std::size_t __count) { + if (__libcpp_is_constant_evaluated()) { + for (std::size_t __n = 0; __n != __count; ++__n) + __dest[__n] = __src[__n]; + } else { + _VSTD::memcpy(__dest, __src, __count); + } + return __dest + __count; +} template struct _LIBCPP_TEMPLATE_VIS allocator_traits @@ -1712,7 +1721,7 @@ bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) { static_assert(__is_cpp17_move_insertable<_Alloc>::value, "The specified type does not meet the requirements of Cpp17MoveInsertible"); @@ -1732,17 +1741,17 @@ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && is_trivially_move_constructible<_Tp>::value >::type> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) { - _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); + _VSTD::__libcpp_memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); __begin2 += _Np; } } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) { typedef allocator_traits<_Alloc> _Traits; for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) { @@ -1759,17 +1768,17 @@ is_same<_RawSource, _RawDest>::value && (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value) >::type> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) { ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) { - _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest)); + _VSTD::__libcpp_memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest)); __begin2 += _Np; } } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) { static_assert(__is_cpp17_move_insertable<_Alloc>::value, "The specified type does not meet the requirements of Cpp17MoveInsertable"); @@ -1790,12 +1799,12 @@ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && is_trivially_move_constructible<_Tp>::value >::type> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) { ptrdiff_t _Np = __end1 - __begin1; __end2 -= _Np; if (_Np > 0) - _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); + _VSTD::__libcpp_memcpy(__end2, __begin1, _Np * sizeof(_Tp)); } template @@ -1972,9 +1981,9 @@ : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} #endif - - _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + reference __get() _NOEXCEPT { return __value_; } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference __get() const _NOEXCEPT { return __value_; } private: @@ -2011,8 +2020,9 @@ : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} #endif - _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + reference __get() _NOEXCEPT { return *this; } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference __get() const _NOEXCEPT { return *this; } }; @@ -2057,27 +2067,27 @@ typename __make_tuple_indices::type()) {} #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT { return static_cast<_Base1&>(*this).__get(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::const_reference first() const _NOEXCEPT { return static_cast<_Base1 const&>(*this).__get(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT { return static_cast<_Base2&>(*this).__get(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::const_reference second() const _NOEXCEPT { return static_cast<_Base2 const&>(*this).__get(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) @@ -2089,7 +2099,7 @@ }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) { @@ -4887,7 +4897,7 @@ // --- Helper for container swap -- template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc & __a1, _Alloc & __a2) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT @@ -4900,7 +4910,7 @@ } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT @@ -4913,7 +4923,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} template > diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -302,7 +302,7 @@ class _LIBCPP_TEMPLATE_VIS __vector_base_common { protected: - _LIBCPP_INLINE_VISIBILITY __vector_base_common() {} + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __vector_base_common() {} _LIBCPP_NORETURN void __throw_length_error() const; _LIBCPP_NORETURN void __throw_out_of_range() const; }; @@ -345,43 +345,43 @@ pointer __end_; __compressed_pair __end_cap_; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; #endif - ~__vector_base(); + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__vector_base(); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {__destruct_at_end(__begin_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return static_cast(__end_cap() - __begin_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base& __c) {__copy_assign_alloc(__c, integral_constant());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__vector_base& __c) _NOEXCEPT_( !__alloc_traits::propagate_on_container_move_assignment::value || @@ -389,7 +389,7 @@ {__move_assign_alloc(__c, integral_constant());} private: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base& __c, true_type) { if (__alloc() != __c.__alloc()) @@ -401,25 +401,25 @@ __alloc() = __c.__alloc(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base&, false_type) {} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__vector_base& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__vector_base&, false_type) _NOEXCEPT {} }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -430,7 +430,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), @@ -440,7 +440,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) : __begin_(nullptr), __end_(nullptr), @@ -450,7 +450,7 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT : __begin_(nullptr), __end_(nullptr), @@ -458,7 +458,7 @@ #endif template -__vector_base<_Tp, _Allocator>::~__vector_base() +_LIBCPP_CONSTEXPR_AFTER_CXX17 __vector_base<_Tp, _Allocator>::~__vector_base() { if (__begin_ != nullptr) { @@ -493,14 +493,14 @@ static_assert((is_same::value), "Allocator::value_type must be same type as value_type"); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector() _NOEXCEPT_(is_nothrow_default_constructible::value) { #if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->__insert_c(this); #endif } - _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value) #else @@ -512,13 +512,14 @@ __get_db()->__insert_c(this); #endif } - explicit vector(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n); #if _LIBCPP_STD_VER > 11 - explicit vector(size_type __n, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a); #endif - vector(size_type __n, const value_type& __x); - vector(size_type __n, const value_type& __x, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x, const allocator_type& __a); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && !__is_cpp17_forward_iterator<_InputIterator>::value && @@ -527,6 +528,7 @@ typename iterator_traits<_InputIterator>::reference>::value, _InputIterator>::type __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && !__is_cpp17_forward_iterator<_InputIterator>::value && @@ -534,6 +536,7 @@ value_type, typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && is_constructible< @@ -541,13 +544,14 @@ typename iterator_traits<_ForwardIterator>::reference>::value, _ForwardIterator>::type __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY ~vector() { __annotate_delete(); @@ -556,19 +560,19 @@ #endif } - vector(const vector& __x); - vector(const vector& __x, const allocator_type& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector& operator=(const vector& __x); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(initializer_list __il); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(initializer_list __il, const allocator_type& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(vector&& __x) #if _LIBCPP_STD_VER > 14 _NOEXCEPT; @@ -576,19 +580,20 @@ _NOEXCEPT_(is_nothrow_move_constructible::value); #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(vector&& __x, const allocator_type& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector& operator=(initializer_list __il) {assign(__il.begin(), __il.end()); return *this;} #endif // !_LIBCPP_CXX03_LANG template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator <_InputIterator>::value && @@ -600,6 +605,7 @@ >::type assign(_InputIterator __first, _InputIterator __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -610,113 +616,114 @@ >::type assign(_ForwardIterator __first, _ForwardIterator __last); - void assign(size_type __n, const_reference __u); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return this->__alloc();} - _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return begin();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return end();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT {return rend();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return static_cast(this->__end_ - this->__begin_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return __base::capacity();} - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return this->__begin_ == this->__end_;} - size_type max_size() const _NOEXCEPT; - void reserve(size_type __n); - void shrink_to_fit() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT; - reference at(size_type __n); - const_reference at(size_type __n) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); return *this->__begin_; } - _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); return *this->__begin_; } - _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); return *(this->__end_ - 1); } - _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); return *(this->__end_ - 1); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return _VSTD::__to_address(this->__begin_);} - _LIBCPP_INLINE_VISIBILITY + + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(this->__begin_);} #ifdef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __emplace_back(const value_type& __x) { push_back(__x); } #else template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); } #endif - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY #if _LIBCPP_STD_VER > 14 reference emplace_back(_Args&&... __args); #else @@ -724,19 +731,20 @@ #endif #endif // !_LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back(); - iterator insert(const_iterator __position, const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x); #ifndef _LIBCPP_CXX03_LANG - iterator insert(const_iterator __position, value_type&& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x); template - iterator emplace(const_iterator __position, _Args&&... __args); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args); #endif // !_LIBCPP_CXX03_LANG - iterator insert(const_iterator __position, size_type __n, const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator <_InputIterator>::value && @@ -748,6 +756,7 @@ >::type insert(const_iterator __position, _InputIterator __first, _InputIterator __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -759,15 +768,15 @@ insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __position, initializer_list __il) {return insert(__position, __il.begin(), __il.end());} #endif - _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); - iterator erase(const_iterator __first, const_iterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT { size_type __old_size = size(); @@ -776,10 +785,10 @@ __invalidate_all_iterators(); } - void resize(size_type __sz); - void resize(size_type __sz, const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x); - void swap(vector&) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; #else @@ -787,47 +796,48 @@ __is_nothrow_swappable::value); #endif - bool __invariants() const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; #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; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __dereferenceable(const const_iterator* __i) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __decrementable(const const_iterator* __i) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __addable(const const_iterator* __i, ptrdiff_t __n) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; #endif // _LIBCPP_DEBUG_LEVEL == 2 private: - _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); - _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); - void __vallocate(size_type __n); - void __vdeallocate() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; - void __construct_at_end(size_type __n); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, const_reference __x); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, void >::type __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); - void __append(size_type __n); - void __append(size_type __n, const_reference __x); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(pointer __p) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; - void __swap_out_circular_buffer(__split_buffer& __v); - pointer __swap_out_circular_buffer(__split_buffer& __v, pointer __p); - void __move_range(pointer __from_s, pointer __from_e, pointer __to); - void __move_assign(vector& __c, true_type) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer& __v); + _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer& __v, pointer __p); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); - void __move_assign(vector& __c, false_type) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT { __invalidate_iterators_past(__new_last); @@ -838,15 +848,15 @@ #ifndef _LIBCPP_CXX03_LANG template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY inline void __push_back_slow_path(_Up&& __x); template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY inline void __emplace_back_slow_path(_Args&&... __args); #else template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY inline void __push_back_slow_path(_Up& __x); #endif @@ -855,6 +865,7 @@ // may not meet the AddressSanitizer alignment constraints. // See the documentation for __sanitizer_annotate_contiguous_container for more details. #ifndef _LIBCPP_HAS_NO_ASAN + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __annotate_contiguous_container(const void *__beg, const void *__end, const void *__old_mid, const void *__new_mid) const @@ -864,30 +875,30 @@ __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); } #else - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __annotate_contiguous_container(const void*, const void*, const void*, const void*) const _NOEXCEPT {} #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __annotate_new(size_type __current_size) const _NOEXCEPT { __annotate_contiguous_container(data(), data() + capacity(), data() + capacity(), data() + __current_size); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __annotate_delete() const _NOEXCEPT { __annotate_contiguous_container(data(), data() + capacity(), data() + size(), data() + capacity()); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __annotate_increase(size_type __n) const _NOEXCEPT { __annotate_contiguous_container(data(), data() + capacity(), data() + size(), data() + size() + __n); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __annotate_shrink(size_type __old_size) const _NOEXCEPT { __annotate_contiguous_container(data(), data() + capacity(), @@ -895,13 +906,13 @@ } struct _ConstructTransaction { - explicit _ConstructTransaction(vector &__v, size_type __n) + explicit _LIBCPP_CONSTEXPR_AFTER_CXX17 _ConstructTransaction(vector &__v, size_type __n) : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { #ifndef _LIBCPP_HAS_NO_ASAN __v_.__annotate_increase(__n); #endif } - ~_ConstructTransaction() { + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() { __v_.__end_ = __pos_; #ifndef _LIBCPP_HAS_NO_ASAN if (__pos_ != __new_end_) { @@ -920,7 +931,7 @@ }; template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __construct_one_at_end(_Args&& ...__args) { _ConstructTransaction __tx(*this, 1); __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), @@ -946,6 +957,7 @@ #endif template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v) { @@ -961,6 +973,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v, pointer __p) { @@ -985,6 +998,7 @@ // Postcondition: capacity() == __n // Postcondition: size() == 0 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__vallocate(size_type __n) { @@ -996,6 +1010,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT { @@ -1008,6 +1023,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::max_size() const _NOEXCEPT { @@ -1017,6 +1033,7 @@ // Precondition: __new_size > capacity() template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::__recommend(size_type __new_size) const @@ -1036,6 +1053,7 @@ // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { @@ -1053,6 +1071,7 @@ // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) @@ -1066,6 +1085,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -1082,6 +1102,7 @@ // Postcondition: size() == size() + __n // Exception safety: strong. template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__append(size_type __n) { @@ -1101,6 +1122,7 @@ // Postcondition: size() == size() + __n // Exception safety: strong. template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { @@ -1116,6 +1138,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1130,6 +1153,7 @@ #if _LIBCPP_STD_VER > 11 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) : __base(__a) { @@ -1145,6 +1169,7 @@ #endif template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1158,6 +1183,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) { @@ -1173,6 +1199,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && !__is_cpp17_forward_iterator<_InputIterator>::value && @@ -1190,6 +1217,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && !__is_cpp17_forward_iterator<_InputIterator>::value && @@ -1207,6 +1235,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && is_constructible< @@ -1227,6 +1256,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && is_constructible< @@ -1246,6 +1276,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(const vector& __x) : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) { @@ -1261,6 +1292,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) : __base(__a) { @@ -1278,6 +1310,7 @@ #ifndef _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) #if _LIBCPP_STD_VER > 14 @@ -1298,6 +1331,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) @@ -1323,6 +1357,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il) { @@ -1337,6 +1372,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) : __base(__a) @@ -1352,6 +1388,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) @@ -1363,6 +1400,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value) @@ -1377,6 +1415,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) @@ -1395,6 +1434,7 @@ #endif // !_LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) @@ -1409,6 +1449,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator <_InputIterator>::value && @@ -1427,6 +1468,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -1464,6 +1506,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { @@ -1486,6 +1529,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT @@ -1498,6 +1542,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT @@ -1510,6 +1555,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT @@ -1518,6 +1564,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT @@ -1526,6 +1573,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT @@ -1534,6 +1582,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT @@ -1542,6 +1591,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT @@ -1551,6 +1601,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT @@ -1560,6 +1611,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) { @@ -1569,6 +1621,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::at(size_type __n) const { @@ -1578,6 +1631,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::reserve(size_type __n) { @@ -1590,6 +1644,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { @@ -1613,6 +1668,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void #ifndef _LIBCPP_CXX03_LANG vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) @@ -1629,6 +1685,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) @@ -1644,6 +1701,7 @@ #ifndef _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) @@ -1658,6 +1716,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { @@ -1671,6 +1730,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline #if _LIBCPP_STD_VER > 14 typename vector<_Tp, _Allocator>::reference @@ -1693,6 +1753,7 @@ #endif // !_LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void vector<_Tp, _Allocator>::pop_back() @@ -1702,6 +1763,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) @@ -1722,6 +1784,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { @@ -1744,6 +1807,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) { @@ -1763,6 +1827,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { @@ -1800,6 +1865,7 @@ #ifndef _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { @@ -1833,6 +1899,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { @@ -1868,6 +1935,7 @@ #endif // !_LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { @@ -1911,6 +1979,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_input_iterator <_InputIterator>::value && @@ -1965,6 +2034,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -2016,6 +2086,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::resize(size_type __sz) { @@ -2027,6 +2098,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { @@ -2038,6 +2110,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::swap(vector& __x) #if _LIBCPP_STD_VER >= 14 @@ -2062,6 +2135,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__invariants() const { @@ -2085,6 +2159,7 @@ #if _LIBCPP_DEBUG_LEVEL == 2 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const { @@ -2092,6 +2167,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const { @@ -2099,6 +2175,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const { @@ -2107,6 +2184,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const { @@ -2117,6 +2195,7 @@ #endif // _LIBCPP_DEBUG_LEVEL == 2 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_all_iterators() @@ -2128,6 +2207,7 @@ template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { @@ -3332,6 +3412,7 @@ }; template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3341,6 +3422,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3349,6 +3431,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3357,6 +3440,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3365,6 +3449,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3373,6 +3458,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3381,6 +3467,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) @@ -3391,6 +3478,7 @@ #if _LIBCPP_STD_VER > 17 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { auto __old_size = __c.size(); @@ -3399,6 +3487,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { auto __old_size = __c.size(); diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp @@ -16,7 +16,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(3, true, test_allocator(5)); @@ -42,5 +42,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d; @@ -39,5 +39,14 @@ assert(d[3] == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp @@ -18,7 +18,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); @@ -77,5 +77,14 @@ assert(l2.get_allocator() == lo.get_allocator()); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -42,5 +42,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp @@ -24,8 +24,7 @@ #include "min_allocator.h" template -void -test0() +TEST_CONSTEXPR_CXX20 void test0() { #if TEST_STD_VER > 14 LIBCPP_STATIC_ASSERT((noexcept(C{})), "" ); @@ -45,8 +44,7 @@ } template -void -test1(const typename C::allocator_type& a) +TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a) { #if TEST_STD_VER > 14 LIBCPP_STATIC_ASSERT((noexcept(C{typename C::allocator_type{}})), "" ); @@ -59,7 +57,7 @@ assert(c.get_allocator() == a); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { test0 >(); @@ -76,5 +74,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp @@ -20,8 +20,7 @@ #include "min_allocator.h" template -void -test(Iterator first, Iterator last) +TEST_CONSTEXPR_CXX20 void do_checks(Iterator first, Iterator last) { C c(first, last); LIBCPP_ASSERT(c.__invariants()); @@ -30,22 +29,31 @@ assert(*i == *first); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); - test >(input_iterator(a), input_iterator(an)); - test >(forward_iterator(a), forward_iterator(an)); - test >(bidirectional_iterator(a), bidirectional_iterator(an)); - test >(random_access_iterator(a), random_access_iterator(an)); - test >(a, an); + do_checks >(input_iterator(a), input_iterator(an)); + do_checks >(forward_iterator(a), forward_iterator(an)); + do_checks >(bidirectional_iterator(a), bidirectional_iterator(an)); + do_checks >(random_access_iterator(a), random_access_iterator(an)); + do_checks >(a, an); #if TEST_STD_VER >= 11 - test> >(input_iterator(a), input_iterator(an)); - test> >(forward_iterator(a), forward_iterator(an)); - test> >(bidirectional_iterator(a), bidirectional_iterator(an)); - test> >(random_access_iterator(a), random_access_iterator(an)); - test> >(a, an); + do_checks> >(input_iterator(a), input_iterator(an)); + do_checks> >(forward_iterator(a), forward_iterator(an)); + do_checks> >(bidirectional_iterator(a), bidirectional_iterator(an)); + do_checks> >(random_access_iterator(a), random_access_iterator(an)); + do_checks> >(a, an); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp @@ -21,8 +21,7 @@ #include "min_allocator.h" template -void -test(Iterator first, Iterator last, const typename C::allocator_type& a) +TEST_CONSTEXPR_CXX20 void do_checks(Iterator first, Iterator last, const typename C::allocator_type& a) { C c(first, last, a); LIBCPP_ASSERT(c.__invariants()); @@ -31,28 +30,37 @@ assert(*i == *first); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); { std::allocator alloc; - test >(input_iterator(a), input_iterator(an), alloc); - test >(forward_iterator(a), forward_iterator(an), alloc); - test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); - test >(random_access_iterator(a), random_access_iterator(an), alloc); - test >(a, an, alloc); + do_checks >(input_iterator(a), input_iterator(an), alloc); + do_checks >(forward_iterator(a), forward_iterator(an), alloc); + do_checks >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + do_checks >(random_access_iterator(a), random_access_iterator(an), alloc); + do_checks >(a, an, alloc); } #if TEST_STD_VER >= 11 { min_allocator alloc; - test> >(input_iterator(a), input_iterator(an), alloc); - test> >(forward_iterator(a), forward_iterator(an), alloc); - test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); - test> >(random_access_iterator(a), random_access_iterator(an), alloc); - test> >(a, an, alloc); + do_checks> >(input_iterator(a), input_iterator(an), alloc); + do_checks> >(forward_iterator(a), forward_iterator(an), alloc); + do_checks> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + do_checks> >(random_access_iterator(a), random_access_iterator(an), alloc); + do_checks> >(a, an, alloc); } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp @@ -19,9 +19,8 @@ #include "test_allocator.h" template -void -test2(typename C::size_type n, - typename C::allocator_type const& a = typename C::allocator_type ()) +TEST_CONSTEXPR_CXX20 void test2(typename C::size_type n, + typename C::allocator_type const& a = typename C::allocator_type ()) { #if TEST_STD_VER >= 14 C c(n, a); @@ -37,8 +36,7 @@ } template -void -test1(typename C::size_type n) +TEST_CONSTEXPR_CXX20 void test1(typename C::size_type n) { C c(n); LIBCPP_ASSERT(c.__invariants()); @@ -49,14 +47,13 @@ } template -void -test(typename C::size_type n) +TEST_CONSTEXPR_CXX20 void test(typename C::size_type n) { test1 ( n ); test2 ( n ); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { test >(50); #if TEST_STD_VER >= 11 @@ -64,5 +61,14 @@ test2> >( 100, test_allocator(23)); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp @@ -18,8 +18,7 @@ #include "min_allocator.h" template -void -test(typename C::size_type n, const typename C::value_type& x) +TEST_CONSTEXPR_CXX20 void do_checks(typename C::size_type n, const typename C::value_type& x) { C c(n, x); LIBCPP_ASSERT(c.__invariants()); @@ -28,12 +27,21 @@ assert(*i == x); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { - test >(50, true); + do_checks >(50, true); #if TEST_STD_VER >= 11 - test> >(50, true); + do_checks> >(50, true); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp @@ -18,9 +18,9 @@ #include "min_allocator.h" template -void -test(typename C::size_type n, const typename C::value_type& x, - const typename C::allocator_type& a) +TEST_CONSTEXPR_CXX20 void do_checks(typename C::size_type n, + const typename C::value_type& x, + const typename C::allocator_type& a) { C c(n, x, a); LIBCPP_ASSERT(c.__invariants()); @@ -30,12 +30,21 @@ assert(*i == x); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { - test >(50, true, std::allocator()); + do_checks >(50, true, std::allocator()); #if TEST_STD_VER >= 11 - test> >(50, true, min_allocator()); + do_checks> >(50, true, min_allocator()); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp @@ -19,8 +19,7 @@ #include "min_allocator.h" template -void -test(const C& x) +TEST_CONSTEXPR_CXX20 void do_checks(const C& x) { typename C::size_type s = x.size(); C c(x); @@ -29,12 +28,12 @@ assert(c == x); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); - test(std::vector(a, an)); + do_checks(std::vector(a, an)); } { std::vector > v(3, true, test_allocator(5)); @@ -52,7 +51,7 @@ { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); - test(std::vector>(a, an)); + do_checks(std::vector>(a, an)); } { std::vector > v(3, true, min_allocator()); @@ -62,5 +61,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp @@ -18,8 +18,7 @@ #include "min_allocator.h" template -void -test(const C& x, const typename C::allocator_type& a) +TEST_CONSTEXPR_CXX20 void do_checks(const C& x, const typename C::allocator_type& a) { typename C::size_type s = x.size(); C c(x, a); @@ -28,12 +27,12 @@ assert(c == x); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); - test(std::vector(a, an), std::allocator()); + do_checks(std::vector(a, an), std::allocator()); } { std::vector > l(3, true, test_allocator(5)); @@ -51,7 +50,7 @@ { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); - test(std::vector>(a, an), min_allocator()); + do_checks(std::vector>(a, an), min_allocator()); } { std::vector > l(3, true, min_allocator()); @@ -63,3 +62,12 @@ return 0; } + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -65,5 +65,14 @@ assert(c.back() == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -88,5 +88,14 @@ assert(c.back() == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -43,5 +43,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a1[] = {1, 0, 1}; { @@ -63,5 +63,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a1[] = {1, 0, 1}; { @@ -83,5 +83,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -20,7 +20,7 @@ #include "test_macros.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { for (unsigned i = 1; i < 256; ++i) @@ -41,5 +41,14 @@ } } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d = {true, false, false, true}; @@ -37,5 +37,14 @@ assert(d[3] == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -19,7 +19,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector> d({true, false, false, true}, test_allocator(3)); @@ -40,5 +40,14 @@ assert(d[3] == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d(10, true); @@ -61,5 +61,14 @@ assert(d[13] == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp @@ -20,7 +20,7 @@ #include "test_iterators.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -126,5 +126,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -80,5 +80,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -76,5 +76,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp @@ -22,7 +22,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef bool T; @@ -121,5 +121,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -18,7 +18,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); @@ -90,5 +90,14 @@ } } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -18,7 +18,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); @@ -73,5 +73,14 @@ assert(l2.get_allocator() == min_allocator()); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d; @@ -39,5 +39,14 @@ assert(d[3] == true); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { bool a[] = {0, 1, 1, 0, 1, 0, 0}; @@ -47,5 +47,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp @@ -16,7 +16,7 @@ #include "test_macros.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a[] = {false, true, false, true}; @@ -36,5 +36,14 @@ assert( r1); assert(!r2); - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -52,5 +52,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -48,5 +48,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -50,5 +50,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -36,5 +36,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -59,5 +59,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp @@ -17,7 +17,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v1(100); @@ -96,5 +96,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -24,7 +24,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector T; @@ -52,5 +52,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/access.pass.cpp b/libcxx/test/std/containers/sequences/vector/access.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/access.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/access.pass.cpp @@ -28,8 +28,7 @@ #include "test_macros.h" template -C -make(int size, int start = 0) +TEST_CONSTEXPR_CXX20 C make(int size, int start = 0) { C c; for (int i = 0; i < size; ++i) @@ -37,7 +36,7 @@ return c; } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -117,5 +116,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp b/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp @@ -18,13 +18,13 @@ #include "min_allocator.h" template -void test_contiguous ( const C &c ) +TEST_CONSTEXPR_CXX20 void test_contiguous(const C &c) { for ( size_t i = 0; i < c.size(); ++i ) assert ( *(c.begin() + static_cast(i)) == *(std::addressof(*c.begin()) + i)); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef int T; @@ -50,5 +50,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp @@ -28,7 +28,7 @@ int second; }; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef int T; @@ -167,5 +167,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp @@ -17,7 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -46,5 +46,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp @@ -18,8 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; C c; @@ -43,5 +42,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp @@ -19,7 +19,7 @@ #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { { typedef limited_allocator A; typedef std::vector C; @@ -45,5 +45,15 @@ assert(c.max_size() <= alloc_max_size(c.get_allocator())); } + return true; +} + +int main(int, char**) { + test(); + +#if TEST_STD_VER > 17 + static_assert(test()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp @@ -17,8 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; v.reserve(10); @@ -68,5 +67,16 @@ } #endif + return true; +} + +int main(int, char**) +{ + tests(); + +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -19,8 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); v.resize(50); @@ -81,5 +80,16 @@ } #endif + return true; +} + +int main(int, char**) +{ + tests(); + +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp @@ -17,8 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); v.resize(50, 1); @@ -75,5 +74,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp @@ -17,8 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); v.push_back(1); @@ -60,5 +59,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -59,5 +59,16 @@ } #endif + return true; +} + +int main(int, char**) +{ + tests(); + +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp @@ -17,8 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v1(100); std::vector v2(200); @@ -48,5 +47,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp @@ -16,8 +16,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(3, 2, test_allocator(5)); std::vector > l2(l, test_allocator(3)); @@ -42,5 +41,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp @@ -20,7 +20,7 @@ #include "asan_testing.h" template -void test ( Vec &v ) +TEST_CONSTEXPR_CXX20 void do_checks(Vec &v) { v.assign({3, 4, 5, 6}); assert(v.size() == 4); @@ -31,24 +31,32 @@ assert(v[3] == 6); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { - typedef std::vector V; - V d1; - V d2; - d2.reserve(10); // no reallocation during assign. - test(d1); - test(d2); + typedef std::vector V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + do_checks(d1); + do_checks(d2); } { - typedef std::vector> V; - V d1; - V d2; - d2.reserve(10); // no reallocation during assign. - test(d1); - test(d2); + typedef std::vector> V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + do_checks(d1); + do_checks(d2); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp @@ -23,7 +23,7 @@ #endif -void test_emplaceable_concept() { +TEST_CONSTEXPR_CXX20 bool test_emplaceable_concept() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -64,13 +64,17 @@ } } #endif -} - + return true; +} int main(int, char**) { test_emplaceable_concept(); - return 0; +#if TEST_STD_VER > 17 + static_assert(test_emplaceable_concept()); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp @@ -20,8 +20,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); std::vector > lo(test_allocator(5)); @@ -97,5 +96,14 @@ assert(is_contiguous_container_asan_correct(l2)); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp @@ -18,10 +18,10 @@ #include "min_allocator.h" #include "asan_testing.h" -bool is6(int x) { return x == 6; } +TEST_CONSTEXPR bool is6(int x) { return x == 6; } template -void test ( Vec &v ) +TEST_CONSTEXPR_CXX20 void do_checks(Vec &v) { v.assign(5, 6); assert(v.size() == 5); @@ -29,27 +29,35 @@ assert(std::all_of(v.begin(), v.end(), is6)); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { - typedef std::vector V; - V d1; - V d2; - d2.reserve(10); // no reallocation during assign. - test(d1); - test(d2); + typedef std::vector V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + do_checks(d1); + do_checks(d2); } #if TEST_STD_VER >= 11 { - typedef std::vector> V; - V d1; - V d2; - d2.reserve(10); // no reallocation during assign. - test(d1); - test(d2); + typedef std::vector> V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + do_checks(d1); + do_checks(d2); } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp @@ -22,8 +22,7 @@ #include "asan_testing.h" template -void -test0() +TEST_CONSTEXPR_CXX20 void test0() { #if TEST_STD_VER > 14 static_assert((noexcept(C{})), "" ); @@ -45,8 +44,7 @@ } template -void -test1(const typename C::allocator_type& a) +TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a) { #if TEST_STD_VER > 14 static_assert((noexcept(C{typename C::allocator_type{}})), "" ); @@ -60,8 +58,7 @@ LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { test0 >(); test0 >(); @@ -99,5 +96,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -25,7 +25,7 @@ #endif template -void test(Iterator first, Iterator last) { +TEST_CONSTEXPR_CXX20 void do_checks(Iterator first, Iterator last) { C c(first, last); LIBCPP_ASSERT(c.__invariants()); assert(c.size() == static_cast(std::distance(first, last))); @@ -35,47 +35,47 @@ assert(*i == *first); } -static void basic_test_cases() { +TEST_CONSTEXPR_CXX20 void basic_test_cases() { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a) / sizeof(a[0]); - test >(input_iterator(a), - input_iterator(an)); - test >(forward_iterator(a), - forward_iterator(an)); - test >(bidirectional_iterator(a), - bidirectional_iterator(an)); - test >(random_access_iterator(a), - random_access_iterator(an)); - test >(a, an); + do_checks >(input_iterator(a), + input_iterator(an)); + do_checks >(forward_iterator(a), + forward_iterator(an)); + do_checks >(bidirectional_iterator(a), + bidirectional_iterator(an)); + do_checks >(random_access_iterator(a), + random_access_iterator(an)); + do_checks >(a, an); - test > >( + do_checks > >( input_iterator(a), input_iterator(an)); // Add 1 for implementations that dynamically allocate a container proxy. - test > >( + do_checks > >( forward_iterator(a), forward_iterator(an)); - test > >( + do_checks > >( bidirectional_iterator(a), bidirectional_iterator(an)); - test > >( + do_checks > >( random_access_iterator(a), random_access_iterator(an)); - test > >(a, an); + do_checks > >(a, an); #if TEST_STD_VER >= 11 - test > >(input_iterator(a), - input_iterator(an)); - test > >( + do_checks > >(input_iterator(a), + input_iterator(an)); + do_checks > >( forward_iterator(a), forward_iterator(an)); - test > >( + do_checks > >( bidirectional_iterator(a), bidirectional_iterator(an)); - test > >( + do_checks > >( random_access_iterator(a), random_access_iterator(an)); - test >(a, an); + do_checks >(a, an); #endif } -void emplaceable_concept_tests() { +TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -114,7 +114,7 @@ #endif } -void test_ctor_under_alloc() { +TEST_CONSTEXPR_CXX20 void test_ctor_under_alloc() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -151,7 +151,7 @@ struct Der : B1, B2 { int z; }; // Initialize a vector with a different value type. -void test_ctor_with_different_value_type() { +TEST_CONSTEXPR_CXX20 void test_ctor_with_different_value_type() { { // Make sure initialization is performed with each element value, not with // a memory blob. @@ -185,11 +185,20 @@ } -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool tests() { basic_test_cases(); emplaceable_concept_tests(); // See PR34898 test_ctor_under_alloc(); test_ctor_with_different_value_type(); - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -26,7 +26,7 @@ #endif template -void test(Iterator first, Iterator last, const A& a) { +TEST_CONSTEXPR_CXX20 void do_checks(Iterator first, Iterator last, const A& a) { C c(first, last, a); LIBCPP_ASSERT(c.__invariants()); assert(c.size() == static_cast(std::distance(first, last))); @@ -40,53 +40,53 @@ template struct implicit_conv_allocator : min_allocator { - implicit_conv_allocator(void*) {} + TEST_CONSTEXPR_CXX20 implicit_conv_allocator(void*) {} implicit_conv_allocator(const implicit_conv_allocator&) = default; template - implicit_conv_allocator(implicit_conv_allocator) {} + TEST_CONSTEXPR_CXX20 implicit_conv_allocator(implicit_conv_allocator) {} }; #endif -void basic_tests() { +TEST_CONSTEXPR_CXX20 void basic_tests() { { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a) / sizeof(a[0]); std::allocator alloc; - test >(input_iterator(a), - input_iterator(an), alloc); - test >(forward_iterator(a), - forward_iterator(an), alloc); - test >(bidirectional_iterator(a), - bidirectional_iterator(an), alloc); - test >(random_access_iterator(a), - random_access_iterator(an), alloc); - test >(a, an, alloc); + do_checks >(input_iterator(a), + input_iterator(an), alloc); + do_checks >(forward_iterator(a), + forward_iterator(an), alloc); + do_checks >(bidirectional_iterator(a), + bidirectional_iterator(an), alloc); + do_checks >(random_access_iterator(a), + random_access_iterator(an), alloc); + do_checks >(a, an, alloc); } #if TEST_STD_VER >= 11 { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a) / sizeof(a[0]); min_allocator alloc; - test > >( + do_checks > >( input_iterator(a), input_iterator(an), alloc); - test > >( + do_checks > >( forward_iterator(a), forward_iterator(an), alloc); - test > >( + do_checks > >( bidirectional_iterator(a), bidirectional_iterator(an), alloc); - test > >( + do_checks > >( random_access_iterator(a), random_access_iterator(an), alloc); - test > >(a, an, alloc); - test > >(a, an, nullptr); + do_checks > >(a, an, alloc); + do_checks > >(a, an, nullptr); } #endif } -void emplaceable_concept_tests() { +TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -127,7 +127,7 @@ #endif } -void test_ctor_under_alloc() { +TEST_CONSTEXPR_CXX20 void test_ctor_under_alloc() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -162,10 +162,19 @@ #endif } -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool tests() { basic_tests(); emplaceable_concept_tests(); // See PR34898 test_ctor_under_alloc(); - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp @@ -9,6 +9,7 @@ // // explicit vector(size_type n); +// explicit vector(size_type n, const Allocator& alloc = Allocator()); #include #include @@ -20,57 +21,55 @@ #include "asan_testing.h" template -void -test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) +TEST_CONSTEXPR_CXX20 +void test(typename C::size_type n, + typename C::allocator_type const& a = typename C::allocator_type()) { -#if TEST_STD_VER >= 14 - C c(n, a); - LIBCPP_ASSERT(c.__invariants()); - assert(c.size() == n); - assert(c.get_allocator() == a); - LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); - for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) - assert(*i == typename C::value_type()); -#else - ((void)n); - ((void)a); -#endif -} - -template -void -test1(typename C::size_type n) -{ - C c(n); - LIBCPP_ASSERT(c.__invariants()); - assert(c.size() == n); - assert(c.get_allocator() == typename C::allocator_type()); - LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + // Test without a custom allocator + { + C c(n); + LIBCPP_ASSERT(c.__invariants()); + assert(c.size() == n); + assert(c.get_allocator() == typename C::allocator_type()); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); #if TEST_STD_VER >= 11 - for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) - assert(*i == typename C::value_type()); + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) + assert(*i == typename C::value_type()); #endif -} + } -template -void -test(typename C::size_type n) -{ - test1 ( n ); - test2 ( n ); + // Test with a custom allocator +#if TEST_STD_VER >= 14 + { + C c(n, a); + LIBCPP_ASSERT(c.__invariants()); + assert(c.size() == n); + assert(c.get_allocator() == a); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) + assert(*i == typename C::value_type()); + } +#endif } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { test >(50); test >(500); assert(DefaultOnly::count == 0); #if TEST_STD_VER >= 11 - test> >(50); - test> >(500); - test2> >( 100, test_allocator(23)); + test > >(50); + test > >(500); + test > >(100, test_allocator(23)); assert(DefaultOnly::count == 0); #endif - return 0; + return true; +} + +int main(int, char**) { + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp @@ -19,7 +19,7 @@ #include "asan_testing.h" template -void +TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, const typename C::value_type& x) { C c(n, x); @@ -30,8 +30,7 @@ assert(*i == x); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { test >(50, 3); // Add 1 for implementations that dynamically allocate a container proxy. test > >(50, 5); @@ -39,5 +38,14 @@ test> >(50, 3); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp @@ -18,7 +18,7 @@ #include "asan_testing.h" template -void +TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, const typename C::value_type& x, const typename C::allocator_type& a) { @@ -31,12 +31,20 @@ assert(*i == x); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { test >(50, 3, std::allocator()); #if TEST_STD_VER >= 11 test> >(50, 3, min_allocator()); #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp @@ -19,7 +19,7 @@ #include "asan_testing.h" template -void +TEST_CONSTEXPR_CXX20 void test(const C& x) { typename C::size_type s = x.size(); @@ -30,8 +30,7 @@ LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); @@ -75,5 +74,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp @@ -30,8 +30,7 @@ LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); @@ -63,5 +62,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp @@ -29,8 +29,7 @@ struct A {}; -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { // Test the explicit deduction guides { @@ -113,5 +112,14 @@ assert(vec.size() == 0); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp @@ -22,5 +22,5 @@ int main(int, char**) { - return 0; + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp @@ -29,8 +29,7 @@ some_alloc(const some_alloc&); }; -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; static_assert(std::is_nothrow_default_constructible::value, ""); @@ -48,5 +47,14 @@ static_assert(!std::is_nothrow_default_constructible::value, ""); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp @@ -27,7 +27,7 @@ ~some_alloc() noexcept(false); }; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -48,5 +48,14 @@ } #endif // _LIBCPP_VERSION - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp @@ -18,7 +18,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d = {3, 4, 5, 6}; @@ -39,5 +39,14 @@ assert(d[3] == 6); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp @@ -20,7 +20,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector> d({3, 4, 5, 6}, test_allocator(3)); @@ -43,5 +43,14 @@ assert(d[3] == 6); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp @@ -21,7 +21,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); @@ -130,5 +130,14 @@ } } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp @@ -20,7 +20,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector > l(test_allocator(5)); @@ -95,5 +95,14 @@ assert(is_contiguous_container_asan_correct(l2)); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp @@ -93,5 +93,5 @@ } #endif - return 0; + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d; @@ -42,5 +42,14 @@ assert(d[3] == 6); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp @@ -18,15 +18,15 @@ #include "asan_testing.h" struct Nasty { - Nasty() : i_(0) {} - Nasty(int i) : i_(i) {} - ~Nasty() {} + TEST_CONSTEXPR Nasty() : i_(0) {} + TEST_CONSTEXPR Nasty(int i) : i_(i) {} + TEST_CONSTEXPR ~Nasty() {} Nasty * operator&() const { assert(false); return nullptr; } int i_; - }; +}; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -61,5 +61,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp @@ -18,15 +18,15 @@ #include "asan_testing.h" struct Nasty { - Nasty() : i_(0) {} - Nasty(int i) : i_(i) {} - ~Nasty() {} + TEST_CONSTEXPR Nasty() : i_(0) {} + TEST_CONSTEXPR Nasty(int i) : i_(i) {} + TEST_CONSTEXPR ~Nasty() {} Nasty * operator&() const { assert(false); return nullptr; } int i_; - }; +}; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { const std::vector v; @@ -61,5 +61,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp @@ -21,57 +21,65 @@ #include "min_allocator.h" template -void test0(S s, U val, S expected, size_t expected_erased_count) { +TEST_CONSTEXPR_CXX20 void check_erase(S s, U val, S expected, size_t expected_erased_count) { ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase(s, val))); assert(expected_erased_count == std::erase(s, val)); assert(s == expected); } template -void test() +TEST_CONSTEXPR_CXX20 void do_checks() { + check_erase(S(), 1, S(), 0); - test0(S(), 1, S(), 0); + check_erase(S({1}), 1, S(), 1); + check_erase(S({1}), 2, S({1}), 0); - test0(S({1}), 1, S(), 1); - test0(S({1}), 2, S({1}), 0); + check_erase(S({1, 2}), 1, S({2}), 1); + check_erase(S({1, 2}), 2, S({1}), 1); + check_erase(S({1, 2}), 3, S({1, 2}), 0); + check_erase(S({1, 1}), 1, S(), 2); + check_erase(S({1, 1}), 3, S({1, 1}), 0); - test0(S({1, 2}), 1, S({2}), 1); - test0(S({1, 2}), 2, S({1}), 1); - test0(S({1, 2}), 3, S({1, 2}), 0); - test0(S({1, 1}), 1, S(), 2); - test0(S({1, 1}), 3, S({1, 1}), 0); + check_erase(S({1, 2, 3}), 1, S({2, 3}), 1); + check_erase(S({1, 2, 3}), 2, S({1, 3}), 1); + check_erase(S({1, 2, 3}), 3, S({1, 2}), 1); + check_erase(S({1, 2, 3}), 4, S({1, 2, 3}), 0); - test0(S({1, 2, 3}), 1, S({2, 3}), 1); - test0(S({1, 2, 3}), 2, S({1, 3}), 1); - test0(S({1, 2, 3}), 3, S({1, 2}), 1); - test0(S({1, 2, 3}), 4, S({1, 2, 3}), 0); + check_erase(S({1, 1, 1}), 1, S(), 3); + check_erase(S({1, 1, 1}), 2, S({1, 1, 1}), 0); + check_erase(S({1, 1, 2}), 1, S({2}), 2); + check_erase(S({1, 1, 2}), 2, S({1, 1}), 1); + check_erase(S({1, 1, 2}), 3, S({1, 1, 2}), 0); + check_erase(S({1, 2, 2}), 1, S({2, 2}), 1); + check_erase(S({1, 2, 2}), 2, S({1}), 2); + check_erase(S({1, 2, 2}), 3, S({1, 2, 2}), 0); - test0(S({1, 1, 1}), 1, S(), 3); - test0(S({1, 1, 1}), 2, S({1, 1, 1}), 0); - test0(S({1, 1, 2}), 1, S({2}), 2); - test0(S({1, 1, 2}), 2, S({1, 1}), 1); - test0(S({1, 1, 2}), 3, S({1, 1, 2}), 0); - test0(S({1, 2, 2}), 1, S({2, 2}), 1); - test0(S({1, 2, 2}), 2, S({1}), 2); - test0(S({1, 2, 2}), 3, S({1, 2, 2}), 0); - - // Test cross-type erasure - using opt = std::optional; - test0(S({1, 2, 1}), opt(), S({1, 2, 1}), 0); - test0(S({1, 2, 1}), opt(1), S({2}), 2); - test0(S({1, 2, 1}), opt(2), S({1, 1}), 1); - test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0); + // Test cross-type erasure + using opt = std::optional; + check_erase(S({1, 2, 1}), opt(), S({1, 2, 1}), 0); + check_erase(S({1, 2, 1}), opt(1), S({2}), 2); + check_erase(S({1, 2, 1}), opt(2), S({1, 1}), 1); + check_erase(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { - test>(); - test>> (); - test>> (); + do_checks>(); + do_checks>> (); + do_checks>> (); + + do_checks>(); + do_checks>(); - test>(); - test>(); + return true; +} - return 0; +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp @@ -20,14 +20,14 @@ #include "min_allocator.h" template -void test0(S s, Pred p, S expected, size_t expected_erased_count) { +TEST_CONSTEXPR_CXX20 void check_erase_if(S s, Pred p, S expected, size_t expected_erased_count) { ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase_if(s, p))); assert(expected_erased_count == std::erase_if(s, p)); assert(s == expected); } template -void test() +TEST_CONSTEXPR_CXX20 void do_checks() { auto is1 = [](auto v) { return v == 1;}; auto is2 = [](auto v) { return v == 2;}; @@ -36,43 +36,52 @@ auto True = [](auto) { return true; }; auto False = [](auto) { return false; }; - test0(S(), is1, S(), 0); - - test0(S({1}), is1, S(), 1); - test0(S({1}), is2, S({1}), 0); - - test0(S({1, 2}), is1, S({2}), 1); - test0(S({1, 2}), is2, S({1}), 1); - test0(S({1, 2}), is3, S({1, 2}), 0); - test0(S({1, 1}), is1, S(), 2); - test0(S({1, 1}), is3, S({1, 1}), 0); - - test0(S({1, 2, 3}), is1, S({2, 3}), 1); - test0(S({1, 2, 3}), is2, S({1, 3}), 1); - test0(S({1, 2, 3}), is3, S({1, 2}), 1); - test0(S({1, 2, 3}), is4, S({1, 2, 3}), 0); - - test0(S({1, 1, 1}), is1, S(), 3); - test0(S({1, 1, 1}), is2, S({1, 1, 1}), 0); - test0(S({1, 1, 2}), is1, S({2}), 2); - test0(S({1, 1, 2}), is2, S({1, 1}), 1); - test0(S({1, 1, 2}), is3, S({1, 1, 2}), 0); - test0(S({1, 2, 2}), is1, S({2, 2}), 1); - test0(S({1, 2, 2}), is2, S({1}), 2); - test0(S({1, 2, 2}), is3, S({1, 2, 2}), 0); - - test0(S({1, 2, 3}), True, S(), 3); - test0(S({1, 2, 3}), False, S({1, 2, 3}), 0); + check_erase_if(S(), is1, S(), 0); + + check_erase_if(S({1}), is1, S(), 1); + check_erase_if(S({1}), is2, S({1}), 0); + + check_erase_if(S({1, 2}), is1, S({2}), 1); + check_erase_if(S({1, 2}), is2, S({1}), 1); + check_erase_if(S({1, 2}), is3, S({1, 2}), 0); + check_erase_if(S({1, 1}), is1, S(), 2); + check_erase_if(S({1, 1}), is3, S({1, 1}), 0); + + check_erase_if(S({1, 2, 3}), is1, S({2, 3}), 1); + check_erase_if(S({1, 2, 3}), is2, S({1, 3}), 1); + check_erase_if(S({1, 2, 3}), is3, S({1, 2}), 1); + check_erase_if(S({1, 2, 3}), is4, S({1, 2, 3}), 0); + + check_erase_if(S({1, 1, 1}), is1, S(), 3); + check_erase_if(S({1, 1, 1}), is2, S({1, 1, 1}), 0); + check_erase_if(S({1, 1, 2}), is1, S({2}), 2); + check_erase_if(S({1, 1, 2}), is2, S({1, 1}), 1); + check_erase_if(S({1, 1, 2}), is3, S({1, 1, 2}), 0); + check_erase_if(S({1, 2, 2}), is1, S({2, 2}), 1); + check_erase_if(S({1, 2, 2}), is2, S({1}), 2); + check_erase_if(S({1, 2, 2}), is3, S({1, 2, 2}), 0); + + check_erase_if(S({1, 2, 3}), True, S(), 3); + check_erase_if(S({1, 2, 3}), False, S({1, 2, 3}), 0); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { - test>(); - test>> (); - test>> (); + do_checks>(); + do_checks>> (); + do_checks>> (); + + do_checks>(); + do_checks>(); - test>(); - test>(); + return true; +} - return 0; +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp @@ -17,7 +17,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { int a[] = {1, 2, 3}; @@ -40,5 +40,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp @@ -28,10 +28,10 @@ A(const A&); A& operator=(const A&); public: - A(int i, double d) + TEST_CONSTEXPR_CXX14 A(int i, double d) : i_(i), d_(d) {} - A(A&& a) + TEST_CONSTEXPR_CXX14 A(A&& a) : i_(a.i_), d_(a.d_) { @@ -39,7 +39,7 @@ a.d_ = 0; } - A& operator=(A&& a) + TEST_CONSTEXPR_CXX14 A& operator=(A&& a) { i_ = a.i_; d_ = a.d_; @@ -48,11 +48,11 @@ return *this; } - int geti() const {return i_;} - double getd() const {return d_;} + TEST_CONSTEXPR_CXX14 int geti() const {return i_;} + TEST_CONSTEXPR_CXX14 double getd() const {return d_;} }; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector c; @@ -133,5 +133,14 @@ assert(c.back().getd() == 4.5); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp @@ -29,10 +29,10 @@ A(const A&); A& operator=(const A&); public: - A(int i, double d) + TEST_CONSTEXPR_CXX14 A(int i, double d) : i_(i), d_(d) {} - A(A&& a) + TEST_CONSTEXPR_CXX14 A(A&& a) : i_(a.i_), d_(a.d_) { @@ -40,7 +40,7 @@ a.d_ = 0; } - A& operator=(A&& a) + TEST_CONSTEXPR_CXX14 A& operator=(A&& a) { i_ = a.i_; d_ = a.d_; @@ -49,11 +49,11 @@ return *this; } - int geti() const {return i_;} - double getd() const {return d_;} + TEST_CONSTEXPR_CXX14 int geti() const {return i_;} + TEST_CONSTEXPR_CXX14 double getd() const {return d_;} }; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector c; @@ -156,5 +156,14 @@ for (int i = 0; i < sz; ++i) assert(c[i] == i); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -58,5 +58,14 @@ assert(is_contiguous_container_asan_correct(v)); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp @@ -33,7 +33,7 @@ bool Throws::sThrows = false; #endif -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { int a1[] = {1, 2, 3, 4, 5}; @@ -116,5 +116,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp @@ -33,7 +33,7 @@ bool Throws::sThrows = false; #endif -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { int a1[] = {1, 2, 3}; { @@ -154,5 +154,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector d(10, 1); @@ -64,5 +64,14 @@ assert(d[13] == 1); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp @@ -26,7 +26,7 @@ void make_move_iterator(S*) {} } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector V; @@ -182,5 +182,14 @@ s.insert(s.end(), input_iterator(), input_iterator()); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp @@ -21,7 +21,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -63,5 +63,14 @@ assert(v[j] == MoveOnly()); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -112,5 +112,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v(100); @@ -94,5 +94,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp @@ -18,7 +18,7 @@ #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector c; @@ -50,5 +50,14 @@ assert(c[i] == i); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp @@ -18,7 +18,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector c; @@ -110,5 +110,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -21,7 +21,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector c; @@ -55,7 +55,7 @@ // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8). // Use 17 for implementations that dynamically allocate a container proxy // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6). - std::vector > c; + std::vector> c; c.push_back(MoveOnly(0)); assert(c.size() == 1); assert(is_contiguous_container_asan_correct(c)); @@ -111,5 +111,14 @@ assert(c[j] == MoveOnly(j)); } - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { int a1[] = {1, 3, 7, 9, 10}; @@ -180,5 +180,14 @@ } #endif - return 0; + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -86,5 +86,5 @@ } #endif - return 0; + return 0; } diff --git a/libcxx/test/support/DefaultOnly.h b/libcxx/test/support/DefaultOnly.h --- a/libcxx/test/support/DefaultOnly.h +++ b/libcxx/test/support/DefaultOnly.h @@ -6,29 +6,26 @@ // //===----------------------------------------------------------------------===// -#ifndef DEFAULTONLY_H -#define DEFAULTONLY_H +#ifndef TEST_SUPPORT_DEFAULT_ONLY_H +#define TEST_SUPPORT_DEFAULT_ONLY_H #include -class DefaultOnly -{ +#include "test_macros.h" + +class DefaultOnly { int data_; DefaultOnly(const DefaultOnly&); DefaultOnly& operator=(const DefaultOnly&); public: - static int count; - - DefaultOnly() : data_(-1) {++count;} - ~DefaultOnly() {data_ = 0; --count;} + TEST_CONSTEXPR DefaultOnly() : data_(-1) { } + TEST_CONSTEXPR ~DefaultOnly() { data_ = 0; } - friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) - {return x.data_ == y.data_;} - friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) - {return x.data_ < y.data_;} + TEST_CONSTEXPR friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) + {return x.data_ == y.data_;} + TEST_CONSTEXPR friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) + {return x.data_ < y.data_;} }; -int DefaultOnly::count = 0; - -#endif // DEFAULTONLY_H +#endif // TEST_SUPPORT_DEFAULT_ONLY_H diff --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h --- a/libcxx/test/support/asan_testing.h +++ b/libcxx/test/support/asan_testing.h @@ -16,17 +16,19 @@ ( const void *beg, const void *mid, const void *end ); template -bool is_contiguous_container_asan_correct ( const std::vector &c ) +constexpr bool is_contiguous_container_asan_correct ( const std::vector &c ) { - if ( std::is_same >::value && c.data() != NULL) - return __sanitizer_verify_contiguous_container ( + if (std::__libcpp_is_constant_evaluated()) + return true; + if (std::is_same >::value && c.data() != NULL) + return __sanitizer_verify_contiguous_container( c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0; return true; } #else template -bool is_contiguous_container_asan_correct ( const std::vector &) +constexpr bool is_contiguous_container_asan_correct ( const std::vector &) { return true; } diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h --- a/libcxx/test/support/test_allocator.h +++ b/libcxx/test/support/test_allocator.h @@ -21,29 +21,38 @@ #include "test_macros.h" template -inline typename std::allocator_traits::size_type -alloc_max_size(Alloc const &a) { - typedef std::allocator_traits AT; - return AT::max_size(a); +TEST_CONSTEXPR +typename std::allocator_traits::size_type alloc_max_size(Alloc const &a) { + return std::allocator_traits::max_size(a); } class test_alloc_base { protected: - static int time_to_throw; + int time_to_throw; public: - static int throw_after; - static int count; - static int alloc_count; - static int copied; - static int moved; - static int converted; + int throw_after; + int count; + int alloc_count; + int copied; + int moved; + int converted; + + TEST_CONSTEXPR test_alloc_base() + : time_to_throw(0) + , throw_after(INT_MAX) + , count(0) + , alloc_count(0) + , copied(0) + , moved(0) + , converted(0) + { } const static int destructed_value = -1; const static int default_value = 0; const static int moved_value = INT_MAX; - static void clear() { + TEST_CONSTEXPR_CXX14 void clear() { assert(count == 0 && "clearing leaking allocator data?"); count = 0; time_to_throw = 0; @@ -52,21 +61,13 @@ clear_ctor_counters(); } - static void clear_ctor_counters() { + TEST_CONSTEXPR_CXX14 void clear_ctor_counters() { copied = 0; moved = 0; converted = 0; } }; -int test_alloc_base::count = 0; -int test_alloc_base::time_to_throw = 0; -int test_alloc_base::alloc_count = 0; -int test_alloc_base::throw_after = INT_MAX; -int test_alloc_base::copied = 0; -int test_alloc_base::moved = 0; -int test_alloc_base::converted = 0; - template class test_allocator : public test_alloc_base @@ -86,19 +87,27 @@ template struct rebind {typedef test_allocator other;}; - test_allocator() TEST_NOEXCEPT : data_(0), id_(0) {++count;} - explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT : data_(i), id_(id) - {++count;} - test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), - id_(a.id_) { + TEST_CONSTEXPR_CXX14 test_allocator() TEST_NOEXCEPT + : data_(0), id_(0) + { ++count; } + + TEST_CONSTEXPR_CXX14 explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT + : data_(i), id_(id) + { ++count; } + + TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT + : data_(a.data_), id_(a.id_) + { ++count; ++copied; assert(a.data_ != destructed_value && a.id_ != destructed_value && "copying from destroyed allocator"); } + #if TEST_STD_VER >= 11 - test_allocator(test_allocator&& a) TEST_NOEXCEPT : data_(a.data_), - id_(a.id_) { + TEST_CONSTEXPR_CXX14 test_allocator(test_allocator&& a) TEST_NOEXCEPT + : data_(a.data_), id_(a.id_) + { ++count; ++moved; assert(a.data_ != destructed_value && a.id_ != destructed_value && @@ -108,53 +117,70 @@ } #endif template - test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), - id_(a.id_) { + TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT + : data_(a.data_), id_(a.id_) + { ++count; ++converted; } - ~test_allocator() TEST_NOEXCEPT { + + TEST_CONSTEXPR_CXX20 ~test_allocator() TEST_NOEXCEPT { assert(data_ >= 0); assert(id_ >= 0); --count; data_ = destructed_value; id_ = destructed_value; } - pointer address(reference x) const {return &x;} - const_pointer address(const_reference x) const {return &x;} - pointer allocate(size_type n, const void* = 0) - { - assert(data_ >= 0); - if (time_to_throw >= throw_after) { + TEST_CONSTEXPR pointer address(reference x) const {return &x;} + TEST_CONSTEXPR const_pointer address(const_reference x) const {return &x;} + TEST_CONSTEXPR_CXX20 pointer allocate(size_type n, const void* = 0) { + assert(data_ >= 0); + if (time_to_throw >= throw_after) { #ifndef TEST_HAS_NO_EXCEPTIONS - throw std::bad_alloc(); + throw std::bad_alloc(); #else - std::terminate(); + std::terminate(); #endif - } - ++time_to_throw; - ++alloc_count; - return (pointer)::operator new(n * sizeof(T)); - } - void deallocate(pointer p, size_type) - {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p);} - size_type max_size() const TEST_NOEXCEPT - {return UINT_MAX / sizeof(T);} + } + ++time_to_throw; + ++alloc_count; + return std::allocator().allocate(n); + } + TEST_CONSTEXPR_CXX20 void deallocate(pointer p, size_type n) { + assert(data_ >= 0); + --alloc_count; + std::allocator().deallocate(p, n); + } + TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { + return UINT_MAX / sizeof(T); + } #if TEST_STD_VER < 11 - void construct(pointer p, const T& val) - {::new(static_cast(p)) T(val);} + void construct(pointer p, const T& val) { + ::new(static_cast(p)) T(val); + } +#elif TEST_STD_VER < 20 + template + void construct(pointer p, U&& val) { + ::new(static_cast(p)) T(std::forward(val)); + } #else - template void construct(pointer p, U&& val) - {::new(static_cast(p)) T(std::forward(val));} + template + constexpr void construct(pointer p, U&& val) { + std::construct_at(p, std::forward(val)); + } #endif - void destroy(pointer p) - {p->~T();} - friend bool operator==(const test_allocator& x, const test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) - {return !(x == y);} - - int get_data() const { return data_; } - int get_id() const { return id_; } + TEST_CONSTEXPR_CXX20 void destroy(pointer p) { + p->~T(); + } + + TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { + return x.data_ == y.data_; + } + TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { + return !(x == y); + } + + TEST_CONSTEXPR int get_data() const { return data_; } + TEST_CONSTEXPR int get_id() const { return id_; } }; template @@ -176,46 +202,73 @@ template struct rebind {typedef non_default_test_allocator other;}; -// non_default_test_allocator() TEST_NOEXCEPT : data_(0) {++count;} - explicit non_default_test_allocator(int i) TEST_NOEXCEPT : data_(i) {++count;} - non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT - : data_(a.data_) {++count;} - template non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT - : data_(a.data_) {++count;} - ~non_default_test_allocator() TEST_NOEXCEPT {assert(data_ >= 0); --count; data_ = -1;} - pointer address(reference x) const {return &x;} - const_pointer address(const_reference x) const {return &x;} - pointer allocate(size_type n, const void* = 0) - { - assert(data_ >= 0); - if (time_to_throw >= throw_after) { + // No default constructor + TEST_CONSTEXPR_CXX14 explicit non_default_test_allocator(int i) TEST_NOEXCEPT + : data_(i) + { ++count; } + + TEST_CONSTEXPR_CXX14 non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT + : data_(a.data_) + { ++count; } + + template + TEST_CONSTEXPR_CXX14 non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT + : data_(a.data_) + { ++count; } + + TEST_CONSTEXPR_CXX20 ~non_default_test_allocator() TEST_NOEXCEPT { + assert(data_ >= 0); + --count; + data_ = -1; + } + TEST_CONSTEXPR pointer address(reference x) const { return &x; } + TEST_CONSTEXPR const_pointer address(const_reference x) const { return &x; } + TEST_CONSTEXPR_CXX20 pointer allocate(size_type n, const void* = 0) { + assert(data_ >= 0); + if (time_to_throw >= throw_after) { #ifndef TEST_HAS_NO_EXCEPTIONS - throw std::bad_alloc(); + throw std::bad_alloc(); #else - std::terminate(); + std::terminate(); #endif - } - ++time_to_throw; - ++alloc_count; - return (pointer)::operator new (n * sizeof(T)); - } - void deallocate(pointer p, size_type) - {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p); } - size_type max_size() const TEST_NOEXCEPT - {return UINT_MAX / sizeof(T);} + } + ++time_to_throw; + ++alloc_count; + return std::allocator().allocate(n); + } + TEST_CONSTEXPR_CXX20 void deallocate(pointer p, size_type n) { + assert(data_ >= 0); + --alloc_count; + std::allocator().deallocate(p, n); + } + TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { + return UINT_MAX / sizeof(T); + } #if TEST_STD_VER < 11 - void construct(pointer p, const T& val) - {::new(static_cast(p)) T(val);} + void construct(pointer p, const T& val) { + ::new(static_cast(p)) T(val); + } +#elif TEST_STD_VER < 20 + template + void construct(pointer p, U&& val) { + ::new(static_cast(p)) T(std::forward(val)); + } #else - template void construct(pointer p, U&& val) - {::new(static_cast(p)) T(std::forward(val));} + template + constexpr void construct(pointer p, U&& val) { + std::construct_at(p, std::forward(val)); + } #endif - void destroy(pointer p) {p->~T();} + TEST_CONSTEXPR_CXX20 void destroy(pointer p) { + p->~T(); + } - friend bool operator==(const non_default_test_allocator& x, const non_default_test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const non_default_test_allocator& x, const non_default_test_allocator& y) - {return !(x == y);} + TEST_CONSTEXPR friend bool operator==(const non_default_test_allocator& x, const non_default_test_allocator& y) { + return x.data_ == y.data_; + } + TEST_CONSTEXPR friend bool operator!=(const non_default_test_allocator& x, const non_default_test_allocator& y) { + return !(x == y); + } }; template <> @@ -236,21 +289,31 @@ template struct rebind {typedef test_allocator other;}; - test_allocator() TEST_NOEXCEPT : data_(0), id_(0) {} - explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT : data_(i), id_(id) {} - test_allocator(const test_allocator& a) TEST_NOEXCEPT - : data_(a.data_), id_(a.id_) {} - template test_allocator(const test_allocator& a) TEST_NOEXCEPT - : data_(a.data_), id_(a.id_) {} - ~test_allocator() TEST_NOEXCEPT {data_ = -1; id_ = -1; } - - int get_id() const { return id_; } - int get_data() const { return data_; } - - friend bool operator==(const test_allocator& x, const test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) - {return !(x == y);} + TEST_CONSTEXPR test_allocator() TEST_NOEXCEPT : data_(0), id_(0) {} + TEST_CONSTEXPR explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT + : data_(i), id_(id) + { } + TEST_CONSTEXPR test_allocator(const test_allocator& a) TEST_NOEXCEPT + : data_(a.data_), id_(a.id_) + { } + template + TEST_CONSTEXPR test_allocator(const test_allocator& a) TEST_NOEXCEPT + : data_(a.data_), id_(a.id_) + { } + TEST_CONSTEXPR_CXX20 ~test_allocator() TEST_NOEXCEPT { + data_ = -1; + id_ = -1; + } + + TEST_CONSTEXPR int get_id() const { return id_; } + TEST_CONSTEXPR int get_data() const { return data_; } + + TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { + return x.data_ == y.data_; + } + TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { + return !(x == y); + } }; template @@ -263,30 +326,38 @@ public: typedef T value_type; - other_allocator() : data_(-1) {} - explicit other_allocator(int i) : data_(i) {} - template other_allocator(const other_allocator& a) - : data_(a.data_) {} - T* allocate(std::size_t n) - {return (T*)::operator new(n * sizeof(T));} - void deallocate(T* p, std::size_t) - {::operator delete((void*)p);} + TEST_CONSTEXPR other_allocator() : data_(-1) {} + TEST_CONSTEXPR explicit other_allocator(int i) : data_(i) {} + template + TEST_CONSTEXPR other_allocator(const other_allocator& a) + : data_(a.data_) + { } + TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { + return std::allocator().allocate(n); + } + TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { + std::allocator().deallocate(p, n); + } - other_allocator select_on_container_copy_construction() const - {return other_allocator(-2);} + TEST_CONSTEXPR other_allocator select_on_container_copy_construction() const { + return other_allocator(-2); + } - friend bool operator==(const other_allocator& x, const other_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const other_allocator& x, const other_allocator& y) - {return !(x == y);} + TEST_CONSTEXPR friend bool operator==(const other_allocator& x, const other_allocator& y) { + return x.data_ == y.data_; + } + TEST_CONSTEXPR friend bool operator!=(const other_allocator& x, const other_allocator& y) { + return !(x == y); + } typedef std::true_type propagate_on_container_copy_assignment; typedef std::true_type propagate_on_container_move_assignment; typedef std::true_type propagate_on_container_swap; #if TEST_STD_VER < 11 - std::size_t max_size() const - {return UINT_MAX / sizeof(T);} + std::size_t max_size() const { + return UINT_MAX / sizeof(T); + } #endif }; @@ -338,59 +409,135 @@ TaggingAllocator() = default; template - TaggingAllocator(const TaggingAllocator&) { } + constexpr TaggingAllocator(const TaggingAllocator&) { } + + TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { + return std::allocator{}.allocate(n); + } - T* allocate(std::size_t n) { return std::allocator{}.allocate(n); } + TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { + std::allocator{}.deallocate(p, n); + } - void deallocate(T* p, std::size_t n) { std::allocator{}.deallocate(p, n); } +#if TEST_STD_VER >= 20 + template + constexpr void construct(Tag_X* p, Args&&... args) { + std::construct_at(p, Ctor_Tag{}, std::forward(args)...); + } + template + constexpr void construct(U* p, Args&&... args) { + std::construct_at(p, std::forward(args)...); + } +#else template - void construct(Tag_X* p, Args&&... args) - { ::new((void*)p) Tag_X(Ctor_Tag{}, std::forward(args)...); } + void construct(Tag_X* p, Args&&... args) { + ::new((void*)p) Tag_X(Ctor_Tag{}, std::forward(args)...); + } template - void construct(U* p, Args&&... args) - { ::new((void*)p) U(std::forward(args)...); } + void construct(U* p, Args&&... args) { + ::new((void*)p) U(std::forward(args)...); + } +#endif template - void destroy(U* p) - { p->~U(); } + TEST_CONSTEXPR_CXX20 void destroy(U* p) { + p->~U(); + } }; template -bool -operator==(const TaggingAllocator&, const TaggingAllocator&) -{ return true; } +TEST_CONSTEXPR bool operator==(const TaggingAllocator&, const TaggingAllocator&) { + return true; +} template -bool -operator!=(const TaggingAllocator&, const TaggingAllocator&) -{ return false; } -#endif +TEST_CONSTEXPR bool operator!=(const TaggingAllocator&, const TaggingAllocator&) { + return false; +} +#endif // >= C++11 + +namespace detail { + // A naive shared_ptr that works within constexpr contexts, but that isn't + // thread safe. + template + struct cheap_shared_ptr { + struct control_block { + int references_; + T resource_; + }; + + control_block* block_; + + TEST_CONSTEXPR cheap_shared_ptr() : block_(nullptr) { } + + TEST_CONSTEXPR_CXX14 cheap_shared_ptr(cheap_shared_ptr const& other) + : block_(other.block_) + { + block_->references_++; + } + + TEST_CONSTEXPR_CXX20 ~cheap_shared_ptr() { + block_->references_--; + if (block_->references_ == 0) { + std::allocator alloc; + typedef std::allocator_traits > AllocTraits; + AllocTraits::destroy(alloc, block_); + AllocTraits::deallocate(alloc, block_, 1); + } + } + + TEST_CONSTEXPR T& operator*() const { + return block_->resource_; + } + + TEST_CONSTEXPR T* operator->() const { + return &block_->resource_; + } + }; + + template + TEST_CONSTEXPR_CXX20 cheap_shared_ptr make_cheap_shared() { + cheap_shared_ptr ptr; + typedef typename cheap_shared_ptr::control_block ControlBlock; + typedef std::allocator_traits > AllocTraits; + + std::allocator alloc; + ptr.block_ = AllocTraits::allocate(alloc, 1); + AllocTraits::construct(alloc, ptr.block_); + ptr.block_->references_ = 1; + return ptr; + } +} // end namespace detail template struct limited_alloc_handle { std::size_t outstanding_; void* last_alloc_; - limited_alloc_handle() : outstanding_(0), last_alloc_(nullptr) {} + TEST_CONSTEXPR limited_alloc_handle() + : outstanding_(0), last_alloc_(nullptr) + { } template - T *allocate(std::size_t N) { + TEST_CONSTEXPR_CXX20 T *allocate(std::size_t N) { if (N + outstanding_ > MaxAllocs) TEST_THROW(std::bad_alloc()); - last_alloc_ = ::operator new(N*sizeof(T)); + T* allocated = std::allocator().allocate(N); + last_alloc_ = allocated; outstanding_ += N; - return static_cast(last_alloc_); + return allocated; } - void deallocate(void* ptr, std::size_t N) { + template + TEST_CONSTEXPR_CXX20 void deallocate(T* ptr, std::size_t N) { if (ptr == last_alloc_) { last_alloc_ = nullptr; assert(outstanding_ >= N); outstanding_ -= N; } - ::operator delete(ptr); + std::allocator().deallocate(ptr, N); } }; @@ -398,8 +545,10 @@ class limited_allocator { template friend class limited_allocator; + template friend bool operator==(limited_allocator const&, limited_allocator const&); + typedef limited_alloc_handle BuffT; - std::shared_ptr handle_; + detail::cheap_shared_ptr handle_; public: typedef T value_type; typedef value_type* pointer; @@ -411,36 +560,45 @@ template struct rebind { typedef limited_allocator other; }; - limited_allocator() : handle_(new BuffT) {} + TEST_CONSTEXPR_CXX20 limited_allocator() + : handle_(detail::make_cheap_shared()) + { } - limited_allocator(limited_allocator const& other) : handle_(other.handle_) {} + TEST_CONSTEXPR limited_allocator(limited_allocator const& other) + : handle_(other.handle_) + { } template - explicit limited_allocator(limited_allocator const& other) - : handle_(other.handle_) {} + TEST_CONSTEXPR explicit limited_allocator(limited_allocator const& other) + : handle_(other.handle_) + { } private: limited_allocator& operator=(const limited_allocator&);// = delete; public: - pointer allocate(size_type n) { return handle_->template allocate(n); } - void deallocate(pointer p, size_type n) { handle_->deallocate(p, n); } - size_type max_size() const {return N;} + TEST_CONSTEXPR_CXX20 pointer allocate(size_type n) { + return handle_->template allocate(n); + } - BuffT* getHandle() const { return handle_.get(); } + TEST_CONSTEXPR_CXX20 void deallocate(pointer p, size_type n) { + handle_->deallocate(p, n); + } + + TEST_CONSTEXPR size_type max_size() const { + return N; + } }; template -inline bool operator==(limited_allocator const& LHS, - limited_allocator const& RHS) { - return LHS.getHandle() == RHS.getHandle(); -} +TEST_CONSTEXPR bool operator==(limited_allocator const& LHS, + limited_allocator const& RHS) +{ return LHS.handle_ == RHS.handle_; } template -inline bool operator!=(limited_allocator const& LHS, - limited_allocator const& RHS) { - return !(LHS == RHS); -} +TEST_CONSTEXPR bool operator!=(limited_allocator const& LHS, + limited_allocator const& RHS) +{ return !(LHS == RHS); } #endif // TEST_ALLOCATOR_H