diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -38,6 +38,8 @@ Implemented Papers ------------------ +- P1004R2 (Making ``std::vector`` constexpr) + Improvements and New Features ----------------------------- diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv --- a/libcxx/docs/Status/Cxx20Papers.csv +++ b/libcxx/docs/Status/Cxx20Papers.csv @@ -107,7 +107,7 @@ "`P0660R10 `__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","","" "`P0784R7 `__","CWG","More constexpr containers","Cologne","|Complete|","12.0" "`P0980R1 `__","LWG","Making std::string constexpr","Cologne","|Complete|","15.0" -"`P1004R2 `__","LWG","Making std::vector constexpr","Cologne","","" +"`P1004R2 `__","LWG","Making std::vector constexpr","Cologne","|Complete|","15.0" "`P1035R7 `__","LWG","Input Range Adaptors","Cologne","","" "`P1065R2 `__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0" "`P1135R6 `__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0" diff --git a/libcxx/include/__algorithm/fill.h b/libcxx/include/__algorithm/fill.h --- a/libcxx/include/__algorithm/fill.h +++ b/libcxx/include/__algorithm/fill.h @@ -20,6 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void diff --git a/libcxx/include/__algorithm/fill_n.h b/libcxx/include/__algorithm/fill_n.h --- a/libcxx/include/__algorithm/fill_n.h +++ b/libcxx/include/__algorithm/fill_n.h @@ -19,6 +19,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -10,10 +10,13 @@ #ifndef _LIBCPP___BIT_REFERENCE #define _LIBCPP___BIT_REFERENCE +#include <__algorithm/copy_n.h> +#include <__algorithm/fill_n.h> #include <__algorithm/min.h> #include <__bits> #include <__config> #include <__iterator/iterator_traits.h> +#include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include #include @@ -51,15 +54,15 @@ friend class __bit_const_reference<_Cp>; friend class __bit_iterator<_Cp, false>; public: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_reference(const __bit_reference&) = default; - _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT {return static_cast(*__seg_ & __mask_);} - _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT {return !static_cast(*this);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_reference& operator=(bool __x) _NOEXCEPT { if (__x) @@ -70,7 +73,7 @@ } #if _LIBCPP_STD_VER > 20 - _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept { + _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept { if (__x) *__seg_ |= __mask_; else @@ -79,15 +82,15 @@ } #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT {return operator=(static_cast(__x));} - _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;} - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT {return __bit_iterator<_Cp, false>(__seg_, static_cast(__libcpp_ctz(__mask_)));} private: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT : __seg_(__s), __mask_(__m) {} }; @@ -98,7 +101,7 @@ }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -108,7 +111,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT { @@ -118,7 +121,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT { @@ -128,7 +131,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -152,14 +155,14 @@ _LIBCPP_INLINE_VISIBILITY __bit_const_reference(const __bit_const_reference&) = default; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT : __seg_(__x.__seg_), __mask_(__x.__mask_) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT {return static_cast(*__seg_ & __mask_);} - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT {return __bit_iterator<_Cp, true>(__seg_, static_cast(__libcpp_ctz(__mask_)));} private: _LIBCPP_INLINE_VISIBILITY @@ -173,12 +176,12 @@ // find template -__bit_iterator<_Cp, _IsConst> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst> __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { typedef __bit_iterator<_Cp, _IsConst> _It; typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; + const int __bits_per_word = _It::__bits_per_word; // do first partial word if (__first.__ctz_ != 0) { @@ -209,7 +212,7 @@ } template -__bit_iterator<_Cp, _IsConst> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst> __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { typedef __bit_iterator<_Cp, _IsConst> _It; @@ -248,7 +251,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst> find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) { @@ -334,7 +337,7 @@ // fill_n template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { typedef __bit_iterator<_Cp, false> _It; @@ -352,7 +355,7 @@ } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type)); + std::fill_n(std::__to_address(__first.__seg_), __nw, 0); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -364,7 +367,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { typedef __bit_iterator<_Cp, false> _It; @@ -382,7 +385,8 @@ } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type)); + // __storage_type is always an unsigned type, so -1 sets all bits + std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -394,7 +398,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) { @@ -410,7 +414,7 @@ // fill template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) { @@ -420,6 +424,7 @@ // copy template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) @@ -449,9 +454,7 @@ // __first.__ctz_ == 0; // do middle words __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(_VSTD::__to_address(__result.__seg_), - _VSTD::__to_address(__first.__seg_), - __nw * sizeof(__storage_type)); + std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_)); __n -= __nw * __bits_per_word; __result.__seg_ += __nw; // do last word @@ -469,6 +472,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) @@ -476,7 +480,7 @@ typedef __bit_iterator<_Cp, _IsConst> _In; typedef typename _In::difference_type difference_type; typedef typename _In::__storage_type __storage_type; - static const int __bits_per_word = _In::__bits_per_word; + const int __bits_per_word = _In::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -547,7 +551,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { @@ -559,7 +563,7 @@ // copy_backward template -__bit_iterator<_Cp, false> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { @@ -590,9 +594,7 @@ __storage_type __nw = __n / __bits_per_word; __result.__seg_ -= __nw; __last.__seg_ -= __nw; - _VSTD::memmove(_VSTD::__to_address(__result.__seg_), - _VSTD::__to_address(__last.__seg_), - __nw * sizeof(__storage_type)); + std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); __n -= __nw * __bits_per_word; // do last word if (__n > 0) @@ -608,7 +610,7 @@ } template -__bit_iterator<_Cp, false> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { @@ -694,7 +696,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { @@ -901,14 +903,19 @@ difference_type __size_; __storage_type __word_[_Np]; - _LIBCPP_INLINE_VISIBILITY static difference_type capacity() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity() {return static_cast(_Np * __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} - _LIBCPP_INLINE_VISIBILITY iterator begin() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) { + if (__libcpp_is_constant_evaluated()) { + for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i) + std::__construct_at(__word_ + __i, 0); + } + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin() { return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); } - _LIBCPP_INLINE_VISIBILITY iterator end() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end() { return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, static_cast(__size_ % __bits_per_word)); @@ -916,7 +923,7 @@ }; template -__bit_iterator<_Cp, false> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) { typedef __bit_iterator<_Cp, false> _I1; @@ -967,14 +974,14 @@ // equal template -bool +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { typedef __bit_iterator<_Cp, _IC1> _It; typedef typename _It::difference_type difference_type; typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; + const int __bits_per_word = _It::__bits_per_word; difference_type __n = __last1 - __first1; if (__n > 0) { @@ -1049,14 +1056,14 @@ } template -bool +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { typedef __bit_iterator<_Cp, _IC1> _It; typedef typename _It::difference_type difference_type; typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; + const int __bits_per_word = _It::__bits_per_word; difference_type __n = __last1 - __first1; if (__n > 0) { @@ -1092,7 +1099,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { @@ -1126,7 +1133,7 @@ unsigned __ctz_; public: - _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 : __seg_(nullptr), __ctz_(0) #endif @@ -1137,7 +1144,7 @@ // When _IsConst=true, this is a converting constructor; // the copy and move constructors are implicitly generated // and trivial. - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} @@ -1146,19 +1153,19 @@ // the implicit generation of a defaulted one is deprecated. // When _IsConst=true, the assignment operators are // implicitly generated and trivial. - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) { __seg_ = __it.__seg_; __ctz_ = __it.__ctz_; return *this; } - _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT { + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT { return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> > ::type(__seg_, __storage_type(1) << __ctz_); } - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++() { if (__ctz_ != __bits_per_word-1) ++__ctz_; @@ -1170,14 +1177,14 @@ return *this; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int) { __bit_iterator __tmp = *this; ++(*this); return __tmp; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--() { if (__ctz_ != 0) --__ctz_; @@ -1189,14 +1196,14 @@ return *this; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int) { __bit_iterator __tmp = *this; --(*this); return __tmp; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n) { if (__n >= 0) __seg_ += (__n + __ctz_) / __bits_per_word; @@ -1208,54 +1215,54 @@ return *this; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n) { return *this += -__n; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const { __bit_iterator __t(*this); __t += __n; return __t; } - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const { __bit_iterator __t(*this); __t -= __n; return __t; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y) {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);} - _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;} - _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) {return !(__x == __y);} - _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);} - _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) {return __y < __x;} - _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) {return !(__y < __x);} - _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) {return !(__x < __y);} private: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT : __seg_(__s), __ctz_(__ctz) {} @@ -1265,26 +1272,44 @@ friend class __bit_const_reference<_Cp>; friend class __bit_iterator<_Cp, true>; template friend struct __bit_array; - template friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); + + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); + + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, + __bit_iterator<_Dp, _IC> __last, + __bit_iterator<_Dp, false> __result); template friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>, __bit_iterator<__C1, false>, __bit_iterator<__C2, false>); @@ -1294,22 +1319,32 @@ template friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>, __bit_iterator<__C1, false>, __bit_iterator<__C2, false>); - template friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>); - template friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool equal(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); - template friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, + __bit_iterator<_Dp, false>, + __bit_iterator<_Dp, false>); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC2>); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC2>); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend bool equal(__bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC1>, + __bit_iterator<_Dp, _IC2>); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); template friend typename __bit_iterator<_Dp, _IC>::difference_type __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); template friend typename __bit_iterator<_Dp, _IC>::difference_type diff --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h --- a/libcxx/include/__memory/construct_at.h +++ b/libcxx/include/__memory/construct_at.h @@ -42,7 +42,8 @@ #if _LIBCPP_STD_VER > 17 return std::construct_at(__location, std::forward<_Args>(__args)...); #else - return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); + return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"), + ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); #endif } diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h --- a/libcxx/include/__memory/pointer_traits.h +++ b/libcxx/include/__memory/pointer_traits.h @@ -122,7 +122,7 @@ private: struct __nat {}; public: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static pointer pointer_to(typename conditional::value, __nat, element_type>::type& __r) {return pointer::pointer_to(__r);} diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h --- a/libcxx/include/__memory/uninitialized_algorithms.h +++ b/libcxx/include/__memory/uninitialized_algorithms.h @@ -509,10 +509,11 @@ template class _AllocatorDestroyRangeReverse { public: - _LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 + _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last) : __alloc_(__alloc), __first_(__first), __last_(__last) {} - _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const { std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_)); } @@ -621,7 +622,7 @@ class _Type = typename iterator_traits<_Iter1>::value_type, class = __enable_if_t::value && is_trivially_move_assignable<_Type>::value && __allocator_has_trivial_move_construct<_Alloc, _Type>::value> > -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) { if (__libcpp_is_constant_evaluated()) { while (__first1 != __last1) { diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -62,107 +62,107 @@ 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 - __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> + _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> __construct_at_end(_InputIter __first, _InputIter __last); template - __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> + _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> __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 +173,7 @@ }; template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __split_buffer<_Tp, _Allocator>::__invariants() const { @@ -203,6 +204,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 +221,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,7 +234,7 @@ template template -__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) { __alloc_rr& __a = this->__alloc(); @@ -254,7 +257,7 @@ template template -__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last)); @@ -265,6 +268,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) @@ -274,6 +278,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) @@ -282,6 +287,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT @@ -291,6 +297,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT @@ -299,6 +306,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) { @@ -314,6 +322,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) @@ -322,6 +331,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) @@ -329,6 +339,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) @@ -336,6 +347,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::~__split_buffer() { clear(); @@ -344,6 +356,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_)), @@ -358,6 +371,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) : __end_cap_(nullptr, __a) { @@ -384,6 +398,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 && @@ -404,6 +419,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| @@ -417,6 +433,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::reserve(size_type __n) { @@ -433,6 +450,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { @@ -460,6 +478,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) { @@ -489,6 +508,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) { @@ -519,6 +539,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) @@ -549,6 +570,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -580,6 +602,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -610,6 +633,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/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -838,6 +838,8 @@ */ +#include <__algorithm/copy.h> +#include <__algorithm/move.h> #include <__assert> // all public C++ headers provide the assertion handler #include <__config> #include <__memory/addressof.h> @@ -941,21 +943,31 @@ struct __temp_value { typedef allocator_traits<_Alloc> _Traits; +#ifdef _LIBCPP_CXX03_LANG typename aligned_storage::type __v; +#else + union { _Tp __v; }; +#endif _Alloc &__a; - _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); } - _Tp & get() { return *__addr(); } + _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() { +#ifdef _LIBCPP_CXX03_LANG + return reinterpret_cast<_Tp*>(std::addressof(__v)); +#else + return std::addressof(__v); +#endif + } + + _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); } template _LIBCPP_NO_CFI - __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { - _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)), - _VSTD::forward<_Args>(__args)...); + _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { + _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...); } - ~__temp_value() { _Traits::destroy(__a, __addr()); } - }; + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); } +}; template struct __is_allocator : false_type {}; diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -360,12 +360,12 @@ 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) { _VSTD::__debug_db_insert_c(this); } - _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 @@ -375,13 +375,14 @@ { _VSTD::__debug_db_insert_c(this); } - 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); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x); template ::value> > + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x, const allocator_type& __a) : __end_cap_(nullptr, __a) { @@ -394,6 +395,7 @@ } template + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< @@ -401,12 +403,14 @@ 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_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< 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< @@ -414,13 +418,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(); @@ -433,24 +438,24 @@ } } - vector(const vector& __x); - vector(const vector& __x, const __type_identity_t& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t& __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& operator=(initializer_list __il) {assign(__il.begin(), __il.end()); return *this;} #endif // !_LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(vector&& __x) #if _LIBCPP_STD_VER > 14 noexcept; @@ -458,14 +463,14 @@ _NOEXCEPT_(is_nothrow_move_constructible::value); #endif - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector(vector&& __x, const __type_identity_t& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); template - typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, @@ -473,6 +478,7 @@ >::type assign(_InputIterator __first, _InputIterator __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -483,119 +489,120 @@ >::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 static_cast(__end_cap() - this->__begin_);} - _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 on an 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 on an 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 on an 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 on an 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_);} - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); - _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 void emplace_back(_Args&&... __args); #endif - _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); - 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); - 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 - typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, @@ -603,6 +610,7 @@ >::type insert(const_iterator __position, _InputIterator __first, _InputIterator __last); template + _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -614,15 +622,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(); @@ -631,10 +639,10 @@ std::__debug_db_invalidate_all(this); } - 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 @@ -642,7 +650,7 @@ __is_nothrow_swappable::value); #endif - bool __invariants() const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; #ifdef _LIBCPP_ENABLE_DEBUG_MODE @@ -661,7 +669,6 @@ _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); - // Allocate space for __n objects // throws length_error if __n > max_size() // throws (probably bad_alloc) if memory run out @@ -669,7 +676,7 @@ // Precondition: __n > 0 // Postcondition: capacity() >= __n // Postcondition: size() == 0 - _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { if (__n > max_size()) __throw_length_error(); auto __allocation = std::__allocate_at_least(__alloc(), __n); @@ -679,46 +686,48 @@ __annotate_new(0); } - 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 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); + if (!__libcpp_is_constant_evaluated()) + __invalidate_iterators_past(__new_last); size_type __old_size = size(); __base_destruct_at_end(__new_last); __annotate_shrink(__old_size); } 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); // The following functions are no-ops outside of AddressSanitizer mode. @@ -726,39 +735,40 @@ // 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 { - if (__beg && is_same::value) + if (!__libcpp_is_constant_evaluated() && __beg && is_same::value) __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(), @@ -766,13 +776,14 @@ } struct _ConstructTransaction { + _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _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_) { @@ -791,7 +802,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_), @@ -799,23 +810,23 @@ ++__tx.__pos_; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return this->__end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return this->__end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return this->__end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return this->__end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { pointer __soon_to_be_end = this->__end_; while (__new_last != __soon_to_be_end) @@ -823,12 +834,12 @@ this->__end_ = __new_last; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __c) {__copy_assign_alloc(__c, integral_constant());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(vector& __c) _NOEXCEPT_( !__alloc_traits::propagate_on_container_move_assignment::value || @@ -846,7 +857,7 @@ _VSTD::__throw_out_of_range("vector"); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __c, true_type) { if (__alloc() != __c.__alloc()) @@ -858,18 +869,18 @@ __alloc() = __c.__alloc(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector&, false_type) {} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(vector& __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&, false_type) _NOEXCEPT {} @@ -894,6 +905,7 @@ #endif template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v) { @@ -911,6 +923,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v, pointer __p) { @@ -931,6 +944,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT { @@ -943,6 +957,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::max_size() const _NOEXCEPT { @@ -952,6 +967,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 @@ -971,6 +987,7 @@ // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { @@ -988,6 +1005,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) @@ -1001,6 +1019,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -1017,6 +1036,7 @@ // Postcondition: size() == size() + __n // Exception safety: strong. template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__append(size_type __n) { @@ -1036,6 +1056,7 @@ // Postcondition: size() == size() + __n // Exception safety: strong. template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { @@ -1051,6 +1072,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n) { _VSTD::__debug_db_insert_c(this); @@ -1063,6 +1085,7 @@ #if _LIBCPP_STD_VER > 11 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) : __end_cap_(nullptr, __a) { @@ -1076,6 +1099,7 @@ #endif template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) { _VSTD::__debug_db_insert_c(this); @@ -1088,6 +1112,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< @@ -1102,6 +1127,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< @@ -1116,6 +1142,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && is_constructible< @@ -1134,6 +1161,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< @@ -1151,6 +1179,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(const vector& __x) : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) { @@ -1164,6 +1193,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t& __a) : __end_cap_(nullptr, __a) { @@ -1177,6 +1207,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) #if _LIBCPP_STD_VER > 14 @@ -1195,6 +1226,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t& __a) : __end_cap_(nullptr, __a) @@ -1218,6 +1250,7 @@ #ifndef _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il) { @@ -1230,6 +1263,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) : __end_cap_(nullptr, __a) @@ -1245,6 +1279,7 @@ #endif // _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) @@ -1256,6 +1291,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value) @@ -1270,6 +1306,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) @@ -1284,6 +1321,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) @@ -1298,7 +1336,7 @@ template template -typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< _Tp, typename iterator_traits<_InputIterator>::reference>::value, @@ -1313,6 +1351,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -1350,6 +1389,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { @@ -1372,6 +1412,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT @@ -1380,6 +1421,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT @@ -1388,6 +1430,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT @@ -1396,6 +1439,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT @@ -1404,6 +1448,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT @@ -1413,6 +1458,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 @@ -1422,6 +1468,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) { @@ -1431,6 +1478,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::at(size_type __n) const { @@ -1440,6 +1488,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::reserve(size_type __n) { @@ -1454,6 +1503,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { @@ -1477,6 +1527,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) { @@ -1489,6 +1540,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) @@ -1502,6 +1554,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) @@ -1516,6 +1569,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { @@ -1529,6 +1583,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline #if _LIBCPP_STD_VER > 14 typename vector<_Tp, _Allocator>::reference @@ -1549,6 +1604,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void vector<_Tp, _Allocator>::pop_back() @@ -1558,6 +1614,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) @@ -1569,12 +1626,14 @@ difference_type __ps = __position - cbegin(); pointer __p = this->__begin_ + __ps; this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); - this->__invalidate_iterators_past(__p-1); + if (!__libcpp_is_constant_evaluated()) + this->__invalidate_iterators_past(__p - 1); iterator __r = iterator(this, __p); return __r; } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { @@ -1587,13 +1646,15 @@ pointer __p = this->__begin_ + (__first - begin()); if (__first != __last) { this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); - this->__invalidate_iterators_past(__p - 1); + if (!__libcpp_is_constant_evaluated()) + this->__invalidate_iterators_past(__p - 1); } iterator __r = iterator(this, __p); return __r; } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) { @@ -1613,13 +1674,15 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, x) called with an iterator not referring to this vector"); pointer __p = this->__begin_ + (__position - begin()); - if (this->__end_ < this->__end_cap()) + // We can't compare unrelated pointers inside constant expressions + if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) { if (__p == this->__end_) { @@ -1645,6 +1708,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { @@ -1675,6 +1739,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { @@ -1705,6 +1770,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { @@ -1713,7 +1779,8 @@ pointer __p = this->__begin_ + (__position - begin()); if (__n > 0) { - if (__n <= static_cast(this->__end_cap() - this->__end_)) + // We can't compare unrelated pointers inside constant expressions + if (!__libcpp_is_constant_evaluated() && __n <= static_cast(this->__end_cap() - this->__end_)) { size_type __old_n = __n; pointer __old_last = this->__end_; @@ -1745,7 +1812,7 @@ template template -typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && is_constructible< _Tp, typename iterator_traits<_InputIterator>::reference>::value, @@ -1793,6 +1860,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value && @@ -1841,6 +1909,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::resize(size_type __sz) { @@ -1852,6 +1921,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { @@ -1863,6 +1933,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector<_Tp, _Allocator>::swap(vector& __x) #if _LIBCPP_STD_VER >= 14 @@ -1885,6 +1956,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector<_Tp, _Allocator>::__invariants() const { @@ -2007,81 +2079,81 @@ typedef __bit_const_reference const_reference; #endif private: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type& __cap() _NOEXCEPT {return __cap_alloc_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const size_type& __cap() const _NOEXCEPT {return __cap_alloc_.first();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __storage_allocator& __alloc() _NOEXCEPT {return __cap_alloc_.second();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const __storage_allocator& __alloc() const _NOEXCEPT {return __cap_alloc_.second();} static const unsigned __bits_per_word = static_cast(sizeof(__storage_type) * CHAR_BIT); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT {return __n * __bits_per_word;} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT {return (__n - 1) / __bits_per_word + 1;} public: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value); #else _NOEXCEPT; #endif - ~vector(); - explicit vector(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector(); + _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& __v); - vector(size_type __n, const value_type& __v, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a); template - vector(_InputIterator __first, _InputIterator __last, + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); template - vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); template - vector(_ForwardIterator __first, _ForwardIterator __last, + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); template - vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); - vector(const vector& __v); - vector(const vector& __v, const allocator_type& __a); - vector& operator=(const vector& __v); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v); #ifndef _LIBCPP_CXX03_LANG - vector(initializer_list __il); - vector(initializer_list __il, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list __il); + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list __il, const allocator_type& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(initializer_list __il) {assign(__il.begin(), __il.end()); return *this;} #endif // !_LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v) #if _LIBCPP_STD_VER > 14 noexcept; #else _NOEXCEPT_(is_nothrow_move_constructible::value); #endif - vector(vector&& __v, const __type_identity_t& __a); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t& __a); + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(vector&& __v) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); @@ -2089,93 +2161,93 @@ typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, void >::type - assign(_InputIterator __first, _InputIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last); template typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, void >::type - assign(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last); - void assign(size_type __n, const value_type& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif - _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT {return allocator_type(this->__alloc());} - size_type max_size() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {return __internal_cap_to_external(__cap());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT {return __size_;} - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool empty() const _NOEXCEPT {return __size_ == 0;} - void reserve(size_type __n); - void shrink_to_fit() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin() _NOEXCEPT {return __make_iter(0);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator begin() const _NOEXCEPT {return __make_iter(0);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end() _NOEXCEPT {return __make_iter(__size_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator end() const _NOEXCEPT {return __make_iter(__size_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator cbegin() const _NOEXCEPT {return __make_iter(0);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator cend() const _NOEXCEPT {return __make_iter(__size_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator crend() const _NOEXCEPT {return rend();} - _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} - _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);} reference at(size_type __n); const_reference at(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} - _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} - _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} - _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);} - void push_back(const value_type& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x); #if _LIBCPP_STD_VER > 11 template #if _LIBCPP_STD_VER > 14 - _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args) #else _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) #endif @@ -2187,54 +2259,54 @@ } #endif - _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;} #if _LIBCPP_STD_VER > 11 template - _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator __position, _Args&&... __args) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args) { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); } #endif - iterator insert(const_iterator __position, const value_type& __x); - iterator insert(const_iterator __position, size_type __n, const value_type& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x); template typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, iterator >::type - insert(const_iterator __position, _InputIterator __first, _InputIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); template typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, iterator >::type - insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT {__size_ = 0;} - void swap(vector&) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; #else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); #endif - static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } + _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } - void resize(size_type __sz, value_type __x = false); - void flip() _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT; - bool __invariants() const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; private: _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI @@ -2254,52 +2326,56 @@ // Precondition: __n > 0 // Postcondition: capacity() >= __n // Postcondition: size() == 0 - _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) { if (__n > max_size()) __throw_length_error(); auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n)); __begin_ = __allocation.ptr; __size_ = 0; __cap() = __allocation.count; + if (__libcpp_is_constant_evaluated()) { + for (size_type __i = 0; __i != __cap(); ++__i) + std::__construct_at(std::__to_address(__begin_) + __i); + } } - void __vdeallocate() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static size_type __align_it(size_type __new_size) _NOEXCEPT {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);} - _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; - _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x); template typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, void >::type - __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); - void __append(size_type __n, const_reference __x); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x); + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference __make_ref(size_type __pos) _NOEXCEPT {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference __make_ref(size_type __pos) const _NOEXCEPT { return __bit_const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator __make_iter(size_type __pos) const _NOEXCEPT {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __copy_assign_alloc(const vector& __v) {__copy_assign_alloc(__v, integral_constant());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __copy_assign_alloc(const vector& __c, true_type) { if (__alloc() != __c.__alloc()) @@ -2307,33 +2383,33 @@ __alloc() = __c.__alloc(); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __copy_assign_alloc(const vector&, false_type) {} - void __move_assign(vector& __c, false_type); - void __move_assign(vector& __c, true_type) + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign_alloc(vector& __c) _NOEXCEPT_( !__storage_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value) {__move_assign_alloc(__c, integral_constant());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign_alloc(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} - size_t __hash_code() const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT; friend class __bit_reference; friend class __bit_const_reference; @@ -2344,7 +2420,7 @@ }; template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::__vdeallocate() _NOEXCEPT { if (this->__begin_ != nullptr) @@ -2357,6 +2433,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::size_type vector::max_size() const _NOEXCEPT { @@ -2369,7 +2446,7 @@ // Precondition: __new_size > capacity() template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::size_type vector::__recommend(size_type __new_size) const { @@ -2387,7 +2464,7 @@ // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::__construct_at_end(size_type __n, bool __x) { @@ -2405,6 +2482,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -2425,7 +2503,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), @@ -2435,7 +2513,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value) @@ -2449,6 +2527,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(size_type __n) : __begin_(nullptr), __size_(0), @@ -2463,6 +2542,7 @@ #if _LIBCPP_STD_VER > 11 template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(size_type __n, const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2477,6 +2557,7 @@ #endif template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(size_type __n, const value_type& __x) : __begin_(nullptr), __size_(0), @@ -2490,6 +2571,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(size_type __n, const value_type& __x, const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2504,6 +2586,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) : __begin_(nullptr), @@ -2530,6 +2613,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) : __begin_(nullptr), @@ -2556,6 +2640,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) : __begin_(nullptr), @@ -2572,6 +2657,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) : __begin_(nullptr), @@ -2589,6 +2675,7 @@ #ifndef _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(initializer_list __il) : __begin_(nullptr), __size_(0), @@ -2603,6 +2690,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(initializer_list __il, const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2619,6 +2707,7 @@ #endif // _LIBCPP_CXX03_LANG template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::~vector() { if (__begin_ != nullptr) @@ -2627,6 +2716,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(const vector& __v) : __begin_(nullptr), __size_(0), @@ -2640,6 +2730,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(const vector& __v, const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2653,6 +2744,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector& vector::operator=(const vector& __v) { @@ -2674,7 +2766,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY vector::vector(vector&& __v) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(vector&& __v) #if _LIBCPP_STD_VER > 14 _NOEXCEPT #else @@ -2689,6 +2781,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 vector::vector(vector&& __v, const __type_identity_t& __a) : __begin_(nullptr), __size_(0), @@ -2710,7 +2803,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& vector::operator=(vector&& __v) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) @@ -2721,7 +2814,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::__move_assign(vector& __c, false_type) { if (__alloc() != __c.__alloc()) @@ -2731,7 +2824,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { @@ -2745,7 +2838,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::assign(size_type __n, const value_type& __x) { __size_ = 0; @@ -2768,7 +2861,7 @@ template template -typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, void >::type vector::assign(_InputIterator __first, _InputIterator __last) @@ -2780,6 +2873,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -2803,7 +2897,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::reserve(size_type __n) { if (__n > capacity()) @@ -2819,7 +2913,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::shrink_to_fit() _NOEXCEPT { if (__external_cap_to_internal(size()) > __cap()) @@ -2857,7 +2951,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::push_back(const value_type& __x) { if (this->__size_ == this->capacity()) @@ -2867,7 +2961,7 @@ } template -typename vector::iterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::iterator vector::insert(const_iterator __position, const value_type& __x) { iterator __r; @@ -2892,7 +2986,7 @@ } template -typename vector::iterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::iterator vector::insert(const_iterator __position, size_type __n, const value_type& __x) { iterator __r; @@ -2919,7 +3013,7 @@ template template -typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, typename vector::iterator >::type vector::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) @@ -2961,6 +3055,7 @@ template template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_cpp17_forward_iterator<_ForwardIterator>::value, @@ -2994,7 +3089,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::iterator vector::erase(const_iterator __position) { @@ -3005,6 +3100,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector::iterator vector::erase(const_iterator __first, const_iterator __last) { @@ -3016,7 +3112,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::swap(vector& __x) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT @@ -3033,7 +3129,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::resize(size_type __sz, value_type __x) { size_type __cs = size(); @@ -3062,7 +3158,7 @@ } template -void +_LIBCPP_CONSTEXPR_AFTER_CXX17 void vector::flip() _NOEXCEPT { // do middle whole words @@ -3081,7 +3177,7 @@ } template -bool +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool vector::__invariants() const { if (this->__begin_ == nullptr) @@ -3100,7 +3196,7 @@ } template -size_t +_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t vector::__hash_code() const _NOEXCEPT { size_t __h = 0; @@ -3122,12 +3218,13 @@ struct _LIBCPP_TEMPLATE_VIS hash > : public __unary_function, size_t> { - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t operator()(const vector& __vec) const _NOEXCEPT {return __vec.__hash_code();} }; template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3137,6 +3234,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3145,6 +3243,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3153,6 +3252,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3161,6 +3261,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3169,6 +3270,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) @@ -3177,6 +3279,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) @@ -3187,6 +3290,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(); @@ -3195,6 +3299,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/src/include/sso_allocator.h b/libcxx/src/include/sso_allocator.h --- a/libcxx/src/include/sso_allocator.h +++ b/libcxx/src/include/sso_allocator.h @@ -41,6 +41,11 @@ typedef _Tp* pointer; typedef _Tp value_type; + template + struct rebind { + using other = __sso_allocator; + }; + _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} template _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp --- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -12,6 +12,8 @@ // map& operator=(const map& m); +// XFAIL: libcpp-has-debug-mode + #include #include #include 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/compare.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp @@ -20,7 +20,7 @@ #include "test_comparisons.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { typedef std::vector VB; { const VB v1, v2; @@ -76,5 +76,14 @@ assert( (std::vector() >= std::vector())); } + 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.bool/const_reference.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp @@ -13,7 +13,7 @@ #include "test_macros.h" -bool test() { +TEST_CONSTEXPR_CXX20 bool test() { using CRefT = std::vector::const_reference; #if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL) ASSERT_SAME_TYPE(CRefT, bool); @@ -32,6 +32,9 @@ 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.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 test(Iterator first, Iterator last) { C c(first, last); LIBCPP_ASSERT(c.__invariants()); @@ -30,7 +29,7 @@ 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]); @@ -47,5 +46,14 @@ test> >(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 test(Iterator first, Iterator last, const typename C::allocator_type& a) { C c(first, last, a); LIBCPP_ASSERT(c.__invariants()); @@ -31,7 +30,7 @@ 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]); @@ -54,5 +53,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_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 test(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); #if TEST_STD_VER >= 11 test> >(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 test(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()); #if TEST_STD_VER >= 11 test> >(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 test(const C& x) { typename C::size_type s = x.size(); C c(x); @@ -29,7 +28,7 @@ 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}; @@ -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 test(const C& x, const typename C::allocator_type& a) { typename C::size_type s = x.size(); C c(x, a); @@ -28,7 +27,7 @@ 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}; @@ -61,5 +60,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/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/enabled_hash.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp @@ -19,12 +19,19 @@ #include "test_macros.h" #include "min_allocator.h" +TEST_CONSTEXPR_CXX20 bool test() { + test_hash_enabled_for_type >(); + test_hash_enabled_for_type>>(); + + return true; +} + int main(int, char**) { test_library_hash_specializations_available(); - { - test_hash_enabled_for_type >(); - test_hash_enabled_for_type>>(); - } + test(); +#if TEST_STD_VER > 17 + static_assert(test()); +#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 @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a1[] = {1, 0, 1}; { @@ -64,5 +64,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 @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { bool a1[] = {1, 0, 1}; { @@ -84,5 +84,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/get_allocator.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp @@ -18,7 +18,7 @@ #include "test_allocator.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { { std::allocator alloc; const std::vector vb(alloc); @@ -30,5 +30,14 @@ assert(vb.get_allocator() == alloc); } + 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.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); @@ -142,5 +142,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); @@ -87,5 +87,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); @@ -84,5 +84,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() { using IterRefT = std::iterator_traits::iterator>::reference; ASSERT_SAME_TYPE(IterRefT, std::vector::reference); @@ -66,6 +66,8 @@ typedef std::vector C; C::iterator i; C::const_iterator j; + (void) i; + (void) j; } #if TEST_STD_VER >= 11 { @@ -101,6 +103,8 @@ typedef std::vector> C; C::iterator i; C::const_iterator j; + (void) i; + (void) j; } #endif #if TEST_STD_VER > 11 @@ -130,5 +134,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() { test_allocator_statistics alloc_stats; { @@ -91,5 +91,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/reference/assign_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp @@ -15,7 +15,7 @@ #include "test_macros.h" -bool test() { +TEST_CONSTEXPR_CXX20 bool test() { std::vector vec; typedef std::vector::reference Ref; vec.push_back(true); @@ -47,6 +47,9 @@ 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.bool/reference/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp @@ -13,7 +13,9 @@ #include #include -bool test() { +#include "test_macros.h" + +TEST_CONSTEXPR_CXX20 bool test() { std::vector vec; typedef std::vector::reference Ref; vec.push_back(true); @@ -71,6 +73,9 @@ 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.bool/reference/ctor_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp @@ -13,7 +13,9 @@ #include #include -bool test() { +#include "test_macros.h" + +TEST_CONSTEXPR_CXX20 bool test() { std::vector vec; typedef std::vector::reference Ref; vec.push_back(true); @@ -28,6 +30,9 @@ 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.bool/reference/flip.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp @@ -13,7 +13,9 @@ #include #include -bool test() { +#include "test_macros.h" + +TEST_CONSTEXPR_CXX20 bool test() { std::vector vec; typedef std::vector::reference Ref; vec.push_back(true); @@ -33,6 +35,9 @@ 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.bool/reference/operator_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp @@ -14,7 +14,9 @@ #include #include -bool test() { +#include "test_macros.h" + +TEST_CONSTEXPR_CXX20 bool test() { std::vector vec; typedef std::vector::reference Ref; static_assert(std::is_convertible::value, ""); @@ -33,6 +35,9 @@ 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.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 @@ -19,7 +19,7 @@ #include "min_allocator.h" #include "test_allocator.h" -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; @@ -59,7 +59,7 @@ } #endif #ifndef TEST_HAS_NO_EXCEPTIONS - { + if (!TEST_IS_CONSTANT_EVALUATED) { std::vector > v; v.reserve(5); try { @@ -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/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); @@ -54,5 +54,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; @@ -56,5 +56,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 @@ -29,9 +29,7 @@ #include "test_macros.h" template -C -make(int size, int start) -{ +TEST_CONSTEXPR_CXX20 C make(int size, int start) { C c; for (int i = 0; i < size; ++i) c.push_back(start + i); @@ -39,7 +37,7 @@ } template -void test_get_basic(Vector& c, int start_value) { +TEST_CONSTEXPR_CXX20 void test_get_basic(Vector& c, int start_value) { const int n = static_cast(c.size()); for (int i = 0; i < n; ++i) assert(c[i] == start_value + i); @@ -47,10 +45,12 @@ assert(c.at(i) == start_value + i); #ifndef TEST_HAS_NO_EXCEPTIONS - try { - TEST_IGNORE_NODISCARD c.at(n); - assert(false); - } catch (const std::out_of_range&) {} + if (!TEST_IS_CONSTANT_EVALUATED) { + try { + TEST_IGNORE_NODISCARD c.at(n); + assert(false); + } catch (const std::out_of_range&) {} + } #endif assert(c.front() == start_value); @@ -58,7 +58,7 @@ } template -void test_get() { +TEST_CONSTEXPR_CXX20 void test_get() { int start_value = 35; Vector c = make(10, start_value); const Vector& cc = c; @@ -67,7 +67,7 @@ } template -void test_set() { +TEST_CONSTEXPR_CXX20 void test_set() { int start_value = 35; const int n = 10; Vector c = make(n, start_value); @@ -93,7 +93,7 @@ } template -void test() { +TEST_CONSTEXPR_CXX20 void test() { test_get(); test_set(); @@ -112,12 +112,18 @@ ASSERT_SAME_TYPE(typename Vector::const_reference, decltype(cc.back())); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { test >(); #if TEST_STD_VER >= 11 test > >(); #endif + 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/compare.pass.cpp b/libcxx/test/std/containers/sequences/vector/compare.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/compare.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/compare.pass.cpp @@ -20,7 +20,7 @@ #include "test_comparisons.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { { const std::vector c1, c2; assert(testComparisons(c1, c2, true, false)); @@ -116,5 +116,14 @@ assert((std::vector() >= std::vector())); } + 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.cons/default.recursive.pass.cpp b/libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp copy from libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp copy to libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp @@ -6,21 +6,18 @@ // //===----------------------------------------------------------------------===// -// -// class vector -// vector(); +// UNSUPPORTED: c++03 +// XFAIL: libcpp-has-debug-mode +#include #include -#include "test_macros.h" +std::vector ca_allocs; -struct X -{ - std::vector q; -}; - -int main(int, char**) -{ +int main(int, char**) { + ca_allocs.push_back(0); + for ([[maybe_unused]] const auto& a : ca_allocs) + ; 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/get_allocator.pass.cpp b/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp @@ -18,7 +18,7 @@ #include "test_allocator.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { { std::allocator alloc; const std::vector v(alloc); @@ -30,5 +30,14 @@ assert(v.get_allocator() == alloc); } + 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/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/reverse_iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp @@ -22,7 +22,7 @@ #include "min_allocator.h" template -void check_vector_reverse_iterators() { +TEST_CONSTEXPR_CXX20 void check_vector_reverse_iterators() { { Vector vec; assert(vec.rbegin() == vec.rend()); @@ -67,11 +67,20 @@ } } -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { check_vector_reverse_iterators >(); #if TEST_STD_VER >= 11 check_vector_reverse_iterators > >(); #endif + 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/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 @@ -18,8 +18,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; v.reserve(10); @@ -50,7 +49,7 @@ assert(is_contiguous_container_asan_correct(v)); } #ifndef TEST_HAS_NO_EXCEPTIONS - { + if (!TEST_IS_CONSTANT_EVALUATED) { std::vector v; size_t sz = v.max_size() + 1; @@ -62,7 +61,7 @@ assert(v.capacity() == 0); } } - { + if (!TEST_IS_CONSTANT_EVALUATED) { std::vector v(10, 42); int* previous_data = v.data(); size_t previous_capacity = v.capacity(); @@ -102,7 +101,7 @@ } #endif #ifndef TEST_HAS_NO_EXCEPTIONS - { + if (!TEST_IS_CONSTANT_EVALUATED) { std::vector > v; v.reserve(50); assert(v.capacity() == 50); @@ -118,5 +117,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); @@ -38,7 +37,7 @@ assert(is_contiguous_container_asan_correct(v)); } #ifndef TEST_HAS_NO_EXCEPTIONS - { + if (!TEST_IS_CONSTANT_EVALUATED) { std::vector > v(100); v.push_back(1); assert(is_contiguous_container_asan_correct(v)); @@ -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,14 @@ } #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 @@ -17,8 +17,7 @@ #include "min_allocator.h" #include "allocators.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)); @@ -81,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/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 test(Vec &v) { v.assign({3, 4, 5, 6}); assert(v.size() == 4); @@ -31,8 +31,7 @@ assert(v[3] == 6); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector V; V d1; @@ -50,5 +49,14 @@ test(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() { +TEST_CONSTEXPR_CXX20 bool test() { #if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; @@ -77,9 +77,14 @@ dst.assign(It(src.data()), It(src.data() + src.size())); assert(dst == src); } + + 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.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 test(Vec &v) { v.assign(5, 6); assert(v.size() == 5); @@ -29,8 +29,7 @@ assert(std::all_of(v.begin(), v.end(), is6)); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector V; V d1; @@ -56,5 +55,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_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 test(Iterator first, Iterator last) { { C c(first, last); LIBCPP_ASSERT(c.__invariants()); @@ -44,7 +44,7 @@ } } -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 >(cpp17_input_iterator(a), @@ -84,7 +84,7 @@ #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}; @@ -160,7 +160,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. @@ -189,12 +189,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(); + test_ctor_under_alloc(); +#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 test(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,16 +40,16 @@ template struct implicit_conv_allocator : min_allocator { - implicit_conv_allocator(void*) {} - implicit_conv_allocator(const implicit_conv_allocator&) = default; + TEST_CONSTEXPR implicit_conv_allocator(void*) {} + TEST_CONSTEXPR implicit_conv_allocator(const implicit_conv_allocator&) = default; template - implicit_conv_allocator(implicit_conv_allocator) {} + TEST_CONSTEXPR 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]); @@ -86,7 +86,7 @@ #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}; @@ -162,9 +162,18 @@ #endif } -int main(int, char**) { +TEST_CONSTEXPR_CXX20 bool test() { basic_tests(); emplaceable_concept_tests(); // See PR34898 + + return true; +} + +int main(int, char**) { + test(); +#if TEST_STD_VER > 17 + static_assert(test()); +#endif test_ctor_under_alloc(); 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 @@ -21,6 +21,7 @@ #include "asan_testing.h" template +TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type()) { @@ -52,24 +53,33 @@ #endif } -void tests() { +TEST_CONSTEXPR_CXX20 bool tests() { test >(0); test >(50); +#if TEST_STD_VER >= 11 + test>>(0); + test>>(50); +#endif + + return true; +} + +int main(int, char**) { + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif test >(0); test >(500); assert(DefaultOnly::count == 0); + #if TEST_STD_VER >= 11 - test>>(0); - test>>(50); test>>(0); test>>(500); test>>(0, test_allocator(23)); test>>(100, test_allocator(23)); assert(DefaultOnly::count == 0); #endif -} -int main(int, char**) { - tests(); 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 >(0, 3); test >(50, 3); // Add 1 for implementations that dynamically allocate a container proxy. @@ -43,5 +42,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,8 +31,7 @@ assert(*i == x); } -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { test >(0, 3, std::allocator()); test >(50, 3, std::allocator()); #if TEST_STD_VER >= 11 @@ -40,5 +39,14 @@ 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]); @@ -87,5 +86,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 @@ -19,7 +19,7 @@ #include "asan_testing.h" template -void +TEST_CONSTEXPR_CXX20 void test(const C& x, const typename C::allocator_type& a) { 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]); @@ -71,5 +70,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 @@ -28,8 +28,7 @@ struct A {}; -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { // Test the explicit deduction guides { @@ -143,5 +142,13 @@ SequenceContainerDeductionGuidesSfinaeAway>(); + 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 @@ -30,8 +30,7 @@ void allocate(size_t); }; -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; static_assert(std::is_nothrow_default_constructible::value, ""); @@ -49,5 +48,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 @@ -28,7 +28,7 @@ void allocate(size_t); }; -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { { typedef std::vector C; @@ -49,5 +49,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)); @@ -49,5 +49,14 @@ assert(is_contiguous_container_asan_correct(d)); } - 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() { test_allocator_statistics alloc_stats; { @@ -131,5 +131,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 @@ -96,5 +96,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_CXX20 ~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_CXX20 ~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,16 +21,15 @@ #include "min_allocator.h" template -void test0(S s, U val, S expected, size_t expected_erased_count) { +TEST_CONSTEXPR_CXX20 void test0(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 test() { - test0(S(), 1, S(), 0); test0(S({1}), 1, S(), 1); @@ -64,7 +63,7 @@ test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { test>(); test>> (); @@ -73,5 +72,14 @@ test>(); test>(); + 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_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 test0(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 test() { auto is1 = [](auto v) { return v == 1;}; auto is2 = [](auto v) { return v == 2;}; @@ -65,7 +65,7 @@ test0(S({1, 2, 3}), False, S({1, 2, 3}), 0); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool tests() { test>(); test>> (); @@ -74,5 +74,14 @@ test>(); test>(); - 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/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 @@ -30,10 +30,10 @@ A(const A&) = delete; A& operator=(const A&) = delete; - 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_) { @@ -41,7 +41,7 @@ a.d_ = 0; } - A& operator=(A&& a) + TEST_CONSTEXPR_CXX14 A& operator=(A&& a) { i_ = a.i_; d_ = a.d_; @@ -50,11 +50,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; @@ -157,5 +157,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,8 +19,7 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool tests() { { std::vector v; v.reserve(3); @@ -71,5 +70,14 @@ assert(v.capacity() == old_capacity); assert(v[4] == 42); } - 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}; @@ -102,19 +102,30 @@ assert(is_contiguous_container_asan_correct(l1)); } #endif + + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + #ifndef TEST_HAS_NO_EXCEPTIONS // Test for LWG2853: // Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T. { - Throws arr[] = {1, 2, 3}; - std::vector v(arr, arr+3); - Throws::sThrows = true; - v.erase(v.begin()); - v.erase(--v.end()); - v.erase(v.begin()); - assert(v.size() == 0); + Throws arr[] = {1, 2, 3}; + std::vector v(arr, arr+3); + Throws::sThrows = true; + v.erase(v.begin()); + v.erase(--v.end()); + v.erase(v.begin()); + assert(v.size() == 0); } #endif - return 0; + 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}; { @@ -140,19 +140,30 @@ assert(is_contiguous_container_asan_correct(outer[1])); } #endif + + return true; +} + +int main(int, char**) +{ + tests(); +#if TEST_STD_VER > 17 + static_assert(tests()); +#endif + #ifndef TEST_HAS_NO_EXCEPTIONS // Test for LWG2853: // Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T. { - Throws arr[] = {1, 2, 3}; - std::vector v(arr, arr+3); - Throws::sThrows = true; - v.erase(v.begin(), --v.end()); - assert(v.size() == 1); - v.erase(v.begin(), v.end()); - assert(v.size() == 0); + Throws arr[] = {1, 2, 3}; + std::vector v(arr, arr+3); + Throws::sThrows = true; + v.erase(v.begin(), --v.end()); + assert(v.size() == 1); + v.erase(v.begin(), v.end()); + assert(v.size() == 0); } #endif - return 0; + 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 @@ -54,10 +54,8 @@ } #endif // TEST_HAS_NO_EXCEPTIONS -int main(int, char**) { -#ifndef TEST_HAS_NO_EXCEPTIONS - test_throwing(); -#endif +TEST_CONSTEXPR_CXX20 bool tests() +{ { std::vector d(10, 1); std::vector::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -101,5 +99,16 @@ assert(d[13] == 1); } + return true; +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_EXCEPTIONS + test_throwing(); +#endif + 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(), cpp17_input_iterator(nullptr), cpp17_input_iterator(nullptr)); } - 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_lvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp @@ -19,8 +19,8 @@ #include "min_allocator.h" #include "asan_testing.h" -int main(int, char**) -{ +TEST_CONSTEXPR_CXX20 bool test() { + { std::vector v(100); const int lvalue = 1; @@ -116,5 +116,15 @@ } #endif + 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.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/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; @@ -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/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp --- a/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp +++ b/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp @@ -8,6 +8,8 @@ // UNSUPPORTED: c++03, c++11 +// XFAIL: libcpp-has-debug-mode + #include #include #include diff --git a/libcxx/test/support/allocators.h b/libcxx/test/support/allocators.h --- a/libcxx/test/support/allocators.h +++ b/libcxx/test/support/allocators.h @@ -9,6 +9,7 @@ #ifndef ALLOCATORS_H #define ALLOCATORS_H +#include #include #include @@ -201,8 +202,8 @@ typedef MaybePOCCAAllocator other; }; - MaybePOCCAAllocator() = default; - MaybePOCCAAllocator(int id, bool* copy_assigned_into) + TEST_CONSTEXPR MaybePOCCAAllocator() = default; + TEST_CONSTEXPR MaybePOCCAAllocator(int id, bool* copy_assigned_into) : id_(id), copy_assigned_into_(copy_assigned_into) {} template @@ -210,7 +211,7 @@ : id_(that.id_), copy_assigned_into_(that.copy_assigned_into_) {} MaybePOCCAAllocator(const MaybePOCCAAllocator&) = default; - MaybePOCCAAllocator& operator=(const MaybePOCCAAllocator& a) + TEST_CONSTEXPR_CXX14 MaybePOCCAAllocator& operator=(const MaybePOCCAAllocator& a) { id_ = a.id(); if (copy_assigned_into_) @@ -218,26 +219,26 @@ return *this; } - T* allocate(std::size_t n) + TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { - return static_cast(::operator new(n * sizeof(T))); + return std::allocator().allocate(n); } - void deallocate(T* ptr, std::size_t) + TEST_CONSTEXPR_CXX20 void deallocate(T* ptr, std::size_t n) { - ::operator delete(ptr); + std::allocator().deallocate(ptr, n); } - int id() const { return id_; } + TEST_CONSTEXPR int id() const { return id_; } template - friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs) + TEST_CONSTEXPR friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs) { return lhs.id() == rhs.id(); } template - friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs) + TEST_CONSTEXPR friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs) { return !(lhs == rhs); } 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 ) +TEST_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 &) +TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector &) { return true; } diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h --- a/libcxx/test/support/poisoned_hash_helper.h +++ b/libcxx/test/support/poisoned_hash_helper.h @@ -24,10 +24,10 @@ // Test that the specified Hash meets the requirements of an enabled hash template -void test_hash_enabled(InputKey const& key = InputKey{}); +TEST_CONSTEXPR_CXX20 void test_hash_enabled(InputKey const& key = InputKey{}); template -void test_hash_enabled_for_type(InputKey const& key = InputKey{}) { +TEST_CONSTEXPR_CXX20 void test_hash_enabled_for_type(InputKey const& key = InputKey{}) { return test_hash_enabled, T, InputKey>(key); } @@ -129,7 +129,7 @@ } // namespace PoisonedHashDetail template -void test_hash_enabled(InputKey const& key) { +TEST_CONSTEXPR_CXX20 void test_hash_enabled(InputKey const& key) { using namespace PoisonedHashDetail; static_assert(std::is_destructible::value, ""); 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,7 +21,7 @@ #include "test_macros.h" template -inline typename std::allocator_traits::size_type alloc_max_size(Alloc const& a) { +TEST_CONSTEXPR_CXX20 inline typename std::allocator_traits::size_type alloc_max_size(Alloc const& a) { typedef std::allocator_traits AT; return AT::max_size(a); } @@ -165,8 +165,12 @@ TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { return UINT_MAX / sizeof(T); } template - TEST_CONSTEXPR_CXX14 void construct(pointer p, U&& val) { + TEST_CONSTEXPR_CXX20 void construct(pointer p, U&& val) { +#if TEST_STD_VER > 17 + std::construct_at(std::to_address(p), std::forward(val)); +#else ::new (static_cast(p)) T(std::forward(val)); +#endif } TEST_CONSTEXPR_CXX14 void destroy(pointer p) { p->~T(); } @@ -399,12 +403,16 @@ TEST_CONSTEXPR TaggingAllocator(const TaggingAllocator&) {} template - void construct(Tag_X* p, Args&&... args) { - ::new ((void*)p) Tag_X(Ctor_Tag(), std::forward(args)...); + TEST_CONSTEXPR_CXX20 void construct(Tag_X* p, Args&&... args) { +#if TEST_STD_VER > 17 + std::construct_at(p, Ctor_Tag{}, std::forward(args)...); +#else + ::new (static_cast(p)) Tag_X(Ctor_Tag(), std::forward(args)...); +#endif } template - void destroy(U* p) { + TEST_CONSTEXPR_CXX20 void destroy(U* p) { p->~U(); } @@ -421,9 +429,10 @@ TEST_CONSTEXPR_CXX20 T* allocate(std::size_t N) { if (N + outstanding_ > MaxAllocs) TEST_THROW(std::bad_alloc()); - last_alloc_ = std::allocator().allocate(N); + auto alloc = std::allocator().allocate(N); + last_alloc_ = alloc; outstanding_ += N; - return static_cast(last_alloc_); + return alloc; } template