diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -308,6 +308,8 @@ ------------------------------------------------- ----------------- ``__cpp_lib_byteswap`` ``202110L`` ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_bitset`` ``202207L`` + ------------------------------------------------- ----------------- ``__cpp_lib_constexpr_cmath`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_constexpr_typeinfo`` *unimplemented* 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,7 @@ Implemented Papers ------------------ - P2499R0 - ``string_view`` range constructor should be ``explicit`` +- P2417R2 - A more constexpr bitset Improvements and New Features ----------------------------- diff --git a/libcxx/docs/Status/Cxx2bPapers.csv b/libcxx/docs/Status/Cxx2bPapers.csv --- a/libcxx/docs/Status/Cxx2bPapers.csv +++ b/libcxx/docs/Status/Cxx2bPapers.csv @@ -69,7 +69,7 @@ "`P2374R4 `__","LWG","``views::cartesian_product``","July 2022","","" "`P2404R3 `__","LWG","Move-only types for ``equality_comparable_with``, ``totally_ordered_with``, and ``three_way_comparable_with``","July 2022","","" "`P2408R5 `__","LWG","Ranges iterators as inputs to non-Ranges algorithms","July 2022","","" -"`P2417R2 `__","LWG","A more ``constexpr`` ``bitset``","July 2022","","" +"`P2417R2 `__","LWG","A more ``constexpr`` ``bitset``","July 2022","|Complete|","16.0" "`P2419R2 `__","LWG","Clarify handling of encodings in localized formatting of chrono types","July 2022","","" "`P2438R2 `__","LWG","``std::string::substr() &&``","July 2022","","" "`P2445R1 `__","LWG","``forward_like``","July 2022","","" diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -263,6 +263,7 @@ // count template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { @@ -1346,6 +1347,7 @@ _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 + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); template friend typename __bit_iterator<_Dp, _IC>::difference_type __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -155,7 +155,7 @@ # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION # endif -# define _LIBCPP_TOSTRING2(x) # x +# define _LIBCPP_TOSTRING2(x) #x # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) # if __cplusplus < 201103L @@ -849,6 +849,12 @@ # define _LIBCPP_CONSTEXPR_AFTER_CXX17 # endif +# if _LIBCPP_STD_VER > 20 +# define _LIBCPP_CONSTEXPR_CXX23 constexpr +# else +# define _LIBCPP_CONSTEXPR_CXX23 +# endif + # if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) # define _LIBCPP_NODISCARD [[nodiscard]] # elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) diff --git a/libcxx/include/bitset b/libcxx/include/bitset --- a/libcxx/include/bitset +++ b/libcxx/include/bitset @@ -42,61 +42,61 @@ template explicit bitset(const charT* str, typename basic_string::size_type n = basic_string::npos, - charT zero = charT('0'), charT one = charT('1')); + charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 template explicit bitset(const basic_string& str, typename basic_string::size_type pos = 0, typename basic_string::size_type n = basic_string::npos, - charT zero = charT('0'), charT one = charT('1')); + charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 // 23.3.5.2 bitset operations: - bitset& operator&=(const bitset& rhs) noexcept; - bitset& operator|=(const bitset& rhs) noexcept; - bitset& operator^=(const bitset& rhs) noexcept; - bitset& operator<<=(size_t pos) noexcept; - bitset& operator>>=(size_t pos) noexcept; - bitset& set() noexcept; - bitset& set(size_t pos, bool val = true); - bitset& reset() noexcept; - bitset& reset(size_t pos); - bitset operator~() const noexcept; - bitset& flip() noexcept; - bitset& flip(size_t pos); + bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23 + bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23 + bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23 + bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23 + bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23 + bitset& set() noexcept; // constexpr since C++23 + bitset& set(size_t pos, bool val = true); // constexpr since C++23 + bitset& reset() noexcept; // constexpr since C++23 + bitset& reset(size_t pos); // constexpr since C++23 + bitset operator~() const noexcept; // constexpr since C++23 + bitset& flip() noexcept; // constexpr since C++23 + bitset& flip(size_t pos); // constexpr since C++23 // element access: - constexpr bool operator[](size_t pos) const; // for b[i]; - reference operator[](size_t pos); // for b[i]; - unsigned long to_ulong() const; - unsigned long long to_ullong() const; - template + constexpr bool operator[](size_t pos) const; // constexpr since C++23 + reference operator[](size_t pos); // constexpr since C++23 + unsigned long to_ulong() const; // constexpr since C++23 + unsigned long long to_ullong() const; // constexpr since C++23 + template // constexpr since C++23 basic_string to_string(charT zero = charT('0'), charT one = charT('1')) const; - template + template // constexpr since C++23 basic_string > to_string(charT zero = charT('0'), charT one = charT('1')) const; - template + template // constexpr since C++23 basic_string, allocator > to_string(charT zero = charT('0'), charT one = charT('1')) const; - basic_string, allocator > to_string(char zero = '0', char one = '1') const; - size_t count() const noexcept; - constexpr size_t size() const noexcept; - bool operator==(const bitset& rhs) const noexcept; - bool operator!=(const bitset& rhs) const noexcept; - bool test(size_t pos) const; - bool all() const noexcept; - bool any() const noexcept; - bool none() const noexcept; - bitset operator<<(size_t pos) const noexcept; - bitset operator>>(size_t pos) const noexcept; + basic_string, allocator > to_string(char zero = '0', char one = '1') const; // constexpr since C++23 + size_t count() const noexcept; // constexpr since C++23 + constexpr size_t size() const noexcept; // constexpr since C++23 + bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23 + bool operator!=(const bitset& rhs) const noexcept; // constexpr since C++23 + bool test(size_t pos) const; // constexpr since C++23 + bool all() const noexcept; // constexpr since C++23 + bool any() const noexcept; // constexpr since C++23 + bool none() const noexcept; // constexpr since C++23 + bitset operator<<(size_t pos) const noexcept; // constexpr since C++23 + bitset operator>>(size_t pos) const noexcept; // constexpr since C++23 }; // 23.3.5.3 bitset operators: template -bitset operator&(const bitset&, const bitset&) noexcept; +bitset operator&(const bitset&, const bitset&) noexcept; // constexpr since C++23 template -bitset operator|(const bitset&, const bitset&) noexcept; +bitset operator|(const bitset&, const bitset&) noexcept; // constexpr since C++23 template -bitset operator^(const bitset&, const bitset&) noexcept; +bitset operator^(const bitset&, const bitset&) noexcept; // constexpr since C++23 template basic_istream& @@ -177,30 +177,30 @@ _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT; - void flip() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void flip() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong() const {return to_ulong(integral_constant());} - _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong() const {return to_ullong(integral_constant());} - bool all() const _NOEXCEPT; - bool any() const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool all() const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool any() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT; private: @@ -209,14 +209,17 @@ _LIBCPP_INLINE_VISIBILITY void __init(unsigned long long __v, true_type) _NOEXCEPT; #endif // _LIBCPP_CXX03_LANG + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong(false_type) const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong(true_type) const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong(false_type) const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong(true_type) const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong(true_type, false_type) const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong(true_type, true_type) const; }; @@ -289,7 +292,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { for (size_type __i = 0; __i < _N_words; ++__i) @@ -298,7 +301,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { for (size_type __i = 0; __i < _N_words; ++__i) @@ -307,7 +310,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { for (size_type __i = 0; __i < _N_words; ++__i) @@ -315,7 +318,7 @@ } template -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT { // do middle whole words @@ -334,7 +337,7 @@ } template -unsigned long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long __bitset<_N_words, _Size>::to_ulong(false_type) const { const_iterator __e = __make_iter(_Size); @@ -347,14 +350,14 @@ template inline -unsigned long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long __bitset<_N_words, _Size>::to_ulong(true_type) const { return __first_[0]; } template -unsigned long long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long __bitset<_N_words, _Size>::to_ullong(false_type) const { const_iterator __e = __make_iter(_Size); @@ -367,7 +370,7 @@ template inline -unsigned long long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type) const { return to_ullong(true_type(), integral_constant()); @@ -375,14 +378,14 @@ template inline -unsigned long long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const { return __first_[0]; } template -unsigned long long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const { unsigned long long __r = __first_[0]; @@ -392,7 +395,7 @@ } template -bool +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT { // do middle whole words @@ -412,7 +415,7 @@ } template -bool +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT { // do middle whole words @@ -473,33 +476,33 @@ _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {return reference(&__first_, __storage_type(1) << __pos);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {return const_reference(&__first_, __storage_type(1) << __pos);} - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void flip() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong() const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong() const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool all() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool any() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -527,7 +530,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { __first_ &= __v.__first_; @@ -535,7 +538,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { __first_ |= __v.__first_; @@ -543,7 +546,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { __first_ ^= __v.__first_; @@ -551,7 +554,7 @@ template inline -void +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT { __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); @@ -561,7 +564,7 @@ template inline -unsigned long +_LIBCPP_CONSTEXPR_CXX23 unsigned long __bitset<1, _Size>::to_ulong() const { return __first_; @@ -569,7 +572,7 @@ template inline -unsigned long long +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long __bitset<1, _Size>::to_ullong() const { return __first_; @@ -577,7 +580,7 @@ template inline -bool +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool __bitset<1, _Size>::all() const _NOEXCEPT { __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); @@ -586,7 +589,7 @@ template inline -bool +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool __bitset<1, _Size>::any() const _NOEXCEPT { __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); @@ -630,26 +633,26 @@ _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 reference __make_ref(size_t) _NOEXCEPT {return reference(nullptr, 1);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT {return const_reference(nullptr, 1);} - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 iterator __make_iter(size_t) _NOEXCEPT {return iterator(nullptr, 0);} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT {return const_iterator(nullptr, 0);} - _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator&=(const __bitset&) _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator|=(const __bitset&) _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void operator^=(const __bitset&) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 void flip() _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;} - _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong() const {return 0;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong() const {return 0;} - _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;} - _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool all() const _NOEXCEPT {return true;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool any() const _NOEXCEPT {return false;} _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} }; @@ -686,10 +689,12 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} template::value> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 explicit bitset(const _CharT* __str, typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); template + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0, typename basic_string<_CharT,_Traits,_Allocator>::size_type __n = @@ -697,24 +702,29 @@ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); // 23.3.5.2 bitset operations: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& operator&=(const bitset& __rhs) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& operator|=(const bitset& __rhs) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& operator^=(const bitset& __rhs) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset& operator<<=(size_t __pos) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset& operator>>=(size_t __pos) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& set() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset& set(size_t __pos, bool __val = true); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& reset() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset& reset(size_t __pos); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset operator~() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset& flip() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset& flip(size_t __pos); // element access: @@ -723,41 +733,43 @@ #else _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);} #endif - _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long to_ulong() const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 unsigned long long to_ullong() const; template + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 basic_string, allocator > to_string(char __zero = '0', char __one = '1') const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 size_t count() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool operator!=(const bitset& __rhs) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool test(size_t __pos) const; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool all() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool any() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bool none() const _NOEXCEPT {return !any();} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT; private: @@ -770,6 +782,7 @@ template template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>::bitset(const _CharT* __str, typename basic_string<_CharT>::size_type __n, _CharT __zero, _CharT __one) @@ -791,6 +804,7 @@ template template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos, typename basic_string<_CharT,_Traits,_Allocator>::size_type __n, @@ -816,6 +830,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT { @@ -825,6 +840,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT { @@ -834,6 +850,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT { @@ -842,6 +859,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT { @@ -852,6 +870,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT { @@ -863,6 +882,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT { @@ -871,6 +891,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) { @@ -883,6 +904,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT { @@ -891,6 +913,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) { @@ -903,6 +926,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> bitset<_Size>::operator~() const _NOEXCEPT { @@ -913,6 +937,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT { @@ -921,6 +946,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) { @@ -934,6 +960,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long bitset<_Size>::to_ulong() const { @@ -942,6 +969,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 unsigned long long bitset<_Size>::to_ullong() const { @@ -950,6 +978,7 @@ template template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, _Traits, _Allocator> bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -965,6 +994,7 @@ template template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -974,6 +1004,7 @@ template template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -982,6 +1013,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 basic_string, allocator > bitset<_Size>::to_string(char __zero, char __one) const { @@ -990,6 +1022,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT { @@ -998,6 +1031,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT { @@ -1006,6 +1040,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT { @@ -1013,6 +1048,7 @@ } template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool bitset<_Size>::test(size_t __pos) const { @@ -1024,6 +1060,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool bitset<_Size>::all() const _NOEXCEPT { @@ -1032,6 +1069,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bool bitset<_Size>::any() const _NOEXCEPT { @@ -1040,6 +1078,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT { @@ -1050,6 +1089,7 @@ template inline +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT { @@ -1059,7 +1099,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { @@ -1069,7 +1109,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { @@ -1079,7 +1119,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_CXX23 bitset<_Size> operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -56,6 +56,7 @@ __cpp_lib_complex_udls 201309L __cpp_lib_concepts 202002L __cpp_lib_constexpr_algorithms 201806L +__cpp_lib_constexpr_bitset 202207L __cpp_lib_constexpr_cmath 202202L __cpp_lib_constexpr_complex 201711L __cpp_lib_constexpr_dynamic_alloc 201907L @@ -380,6 +381,7 @@ // # define __cpp_lib_associative_heterogeneous_erasure 202110L // # define __cpp_lib_bind_back 202202L # define __cpp_lib_byteswap 202110L +# define __cpp_lib_constexpr_bitset 202207L // # define __cpp_lib_constexpr_cmath 202202L // # define __cpp_lib_constexpr_typeinfo 202106L // # define __cpp_lib_invoke_r 202106L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/bitset.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/bitset.version.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/bitset.version.compile.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_feature_test_macro_components.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test the feature test macros defined by + +/* Constant Value + __cpp_lib_constexpr_bitset 202207L [C++2b] +*/ + +#include +#include "test_macros.h" + +#if TEST_STD_VER < 14 + +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + +#elif TEST_STD_VER == 14 + +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + +#elif TEST_STD_VER == 17 + +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + +#elif TEST_STD_VER == 20 + +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + +#elif TEST_STD_VER > 20 + +# ifndef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should be defined in c++2b" +# endif +# if __cpp_lib_constexpr_bitset != 202207L +# error "__cpp_lib_constexpr_bitset should have the value 202207L in c++2b" +# endif + +#endif // TEST_STD_VER > 20 + diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -52,6 +52,7 @@ __cpp_lib_complex_udls 201309L [C++14] __cpp_lib_concepts 202002L [C++20] __cpp_lib_constexpr_algorithms 201806L [C++20] + __cpp_lib_constexpr_bitset 202207L [C++2b] __cpp_lib_constexpr_cmath 202202L [C++2b] __cpp_lib_constexpr_complex 201711L [C++20] __cpp_lib_constexpr_dynamic_alloc 201907L [C++20] @@ -324,6 +325,10 @@ # error "__cpp_lib_constexpr_algorithms should not be defined before c++20" # endif +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + # ifdef __cpp_lib_constexpr_cmath # error "__cpp_lib_constexpr_cmath should not be defined before c++2b" # endif @@ -952,6 +957,10 @@ # error "__cpp_lib_constexpr_algorithms should not be defined before c++20" # endif +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + # ifdef __cpp_lib_constexpr_cmath # error "__cpp_lib_constexpr_cmath should not be defined before c++2b" # endif @@ -1676,6 +1685,10 @@ # error "__cpp_lib_constexpr_algorithms should not be defined before c++20" # endif +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + # ifdef __cpp_lib_constexpr_cmath # error "__cpp_lib_constexpr_cmath should not be defined before c++2b" # endif @@ -2646,6 +2659,10 @@ # error "__cpp_lib_constexpr_algorithms should have the value 201806L in c++20" # endif +# ifdef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should not be defined before c++2b" +# endif + # ifdef __cpp_lib_constexpr_cmath # error "__cpp_lib_constexpr_cmath should not be defined before c++2b" # endif @@ -3865,6 +3882,13 @@ # error "__cpp_lib_constexpr_algorithms should have the value 201806L in c++2b" # endif +# ifndef __cpp_lib_constexpr_bitset +# error "__cpp_lib_constexpr_bitset should be defined in c++2b" +# endif +# if __cpp_lib_constexpr_bitset != 202207L +# error "__cpp_lib_constexpr_bitset should have the value 202207L in c++2b" +# endif + # if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_constexpr_cmath # error "__cpp_lib_constexpr_cmath should be defined in c++2b" diff --git a/libcxx/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp @@ -21,19 +21,19 @@ TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. template -void test_char_pointer_ctor() +TEST_CONSTEXPR_CXX23 void test_char_pointer_ctor() { - { + if (!TEST_IS_CONSTANT_EVALUATED) { #ifndef TEST_HAS_NO_EXCEPTIONS - try { - std::bitset v("xxx1010101010xxxx"); - assert(false); - } - catch (std::invalid_argument&) {} -#endif + try { + std::bitset v("xxx1010101010xxxx"); + assert(false); } + catch (std::invalid_argument&) {} +#endif + } - { + { const char str[] = "1010101010"; std::bitset v(str); std::size_t M = std::min(v.size(), 10); @@ -41,20 +41,29 @@ assert(v[i] == (str[M - 1 - i] == '1')); for (std::size_t i = 10; i < v.size(); ++i) assert(v[i] == false); - } + } +} + +TEST_CONSTEXPR_CXX23 bool test() { + test_char_pointer_ctor<0>(); + test_char_pointer_ctor<1>(); + test_char_pointer_ctor<31>(); + test_char_pointer_ctor<32>(); + test_char_pointer_ctor<33>(); + test_char_pointer_ctor<63>(); + test_char_pointer_ctor<64>(); + test_char_pointer_ctor<65>(); + test_char_pointer_ctor<1000>(); + + return true; } int main(int, char**) { - test_char_pointer_ctor<0>(); - test_char_pointer_ctor<1>(); - test_char_pointer_ctor<31>(); - test_char_pointer_ctor<32>(); - test_char_pointer_ctor<33>(); - test_char_pointer_ctor<63>(); - test_char_pointer_ctor<64>(); - test_char_pointer_ctor<65>(); - test_char_pointer_ctor<1000>(); + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp @@ -14,7 +14,7 @@ #include "test_macros.h" template -void test_default_ctor() +TEST_CONSTEXPR_CXX23 void test_default_ctor() { { TEST_CONSTEXPR std::bitset v1; @@ -30,18 +30,26 @@ #endif } +TEST_CONSTEXPR_CXX23 bool test() { + test_default_ctor<0>(); + test_default_ctor<1>(); + test_default_ctor<31>(); + test_default_ctor<32>(); + test_default_ctor<33>(); + test_default_ctor<63>(); + test_default_ctor<64>(); + test_default_ctor<65>(); + test_default_ctor<1000>(); + + return true; +} int main(int, char**) { - test_default_ctor<0>(); - test_default_ctor<1>(); - test_default_ctor<31>(); - test_default_ctor<32>(); - test_default_ctor<33>(); - test_default_ctor<63>(); - test_default_ctor<64>(); - test_default_ctor<65>(); - test_default_ctor<1000>(); + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp @@ -17,64 +17,60 @@ #include "test_macros.h" template -void test_string_ctor() { +TEST_CONSTEXPR_CXX23 void test_string_ctor() { #ifndef TEST_HAS_NO_EXCEPTIONS - { - try { - std::string s("xxx1010101010xxxx"); - std::bitset v(s, s.size()+1, 10); - assert(false); - } - catch (std::out_of_range&) - { - } - } - { - try { - std::string s("xxx1010101010xxxx"); - std::bitset v(s, 2, 10); - assert(false); - } - catch (std::invalid_argument&) - { - } + if (!TEST_IS_CONSTANT_EVALUATED) { + try { + std::string s("xxx1010101010xxxx"); + std::bitset v(s, s.size()+1, 10); + assert(false); } + catch (std::out_of_range&) { - try { - std::string s("xxxbababababaxxxx"); - std::bitset v(s, 2, 10, 'a', 'b'); - assert(false); - } - catch (std::invalid_argument&) - { - } } -#endif // TEST_HAS_NO_EXCEPTIONS - { + try { std::string s("xxx1010101010xxxx"); - std::bitset v(s, 3, 10); - std::size_t M = std::min(v.size(), 10); - for (std::size_t i = 0; i < M; ++i) - assert(v[i] == (s[3 + M - 1 - i] == '1')); - for (std::size_t i = 10; i < v.size(); ++i) - assert(v[i] == false); + std::bitset v(s, 2, 10); + assert(false); } + catch (std::invalid_argument&) { + } + try { std::string s("xxxbababababaxxxx"); - std::bitset v(s, 3, 10, 'a', 'b'); - std::size_t M = std::min(v.size(), 10); - for (std::size_t i = 0; i < M; ++i) - assert(v[i] == (s[3 + M - 1 - i] == 'b')); - for (std::size_t i = 10; i < v.size(); ++i) - assert(v[i] == false); + std::bitset v(s, 2, 10, 'a', 'b'); + assert(false); } + catch (std::invalid_argument&) + { + } + } +#endif // TEST_HAS_NO_EXCEPTIONS + { + std::string s("xxx1010101010xxxx"); + std::bitset v(s, 3, 10); + std::size_t M = std::min(v.size(), 10); + for (std::size_t i = 0; i < M; ++i) + assert(v[i] == (s[3 + M - 1 - i] == '1')); + for (std::size_t i = 10; i < v.size(); ++i) + assert(v[i] == false); + } + { + std::string s("xxxbababababaxxxx"); + std::bitset v(s, 3, 10, 'a', 'b'); + std::size_t M = std::min(v.size(), 10); + for (std::size_t i = 0; i < M; ++i) + assert(v[i] == (s[3 + M - 1 - i] == 'b')); + for (std::size_t i = 10; i < v.size(); ++i) + assert(v[i] == false); + } } struct Nonsense { virtual ~Nonsense() {} }; -void test_for_non_eager_instantiation() { +TEST_CONSTEXPR_CXX23 void test_for_non_eager_instantiation() { // Ensure we don't accidentally instantiate `std::basic_string` // since it may not be well formed and can cause an error in the // non-immediate context. @@ -82,17 +78,26 @@ static_assert(!std::is_constructible, Nonsense*, size_t, Nonsense&, Nonsense&>::value, ""); } +TEST_CONSTEXPR_CXX23 bool test() { + test_string_ctor<0>(); + test_string_ctor<1>(); + test_string_ctor<31>(); + test_string_ctor<32>(); + test_string_ctor<33>(); + test_string_ctor<63>(); + test_string_ctor<64>(); + test_string_ctor<65>(); + test_string_ctor<1000>(); + test_for_non_eager_instantiation(); + + return true; +} + int main(int, char**) { - test_string_ctor<0>(); - test_string_ctor<1>(); - test_string_ctor<31>(); - test_string_ctor<32>(); - test_string_ctor<33>(); - test_string_ctor<63>(); - test_string_ctor<64>(); - test_string_ctor<65>(); - test_string_ctor<1000>(); - test_for_non_eager_instantiation(); + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp @@ -18,7 +18,7 @@ TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. template -void test_val_ctor() +TEST_CONSTEXPR_CXX23 void test_val_ctor() { { TEST_CONSTEXPR std::bitset v(0xAAAAAAAAAAAAAAAAULL); @@ -37,17 +37,26 @@ #endif } +TEST_CONSTEXPR_CXX23 bool test() { + test_val_ctor<0>(); + test_val_ctor<1>(); + test_val_ctor<31>(); + test_val_ctor<32>(); + test_val_ctor<33>(); + test_val_ctor<63>(); + test_val_ctor<64>(); + test_val_ctor<65>(); + test_val_ctor<1000>(); + + return true; +} + int main(int, char**) { - test_val_ctor<0>(); - test_val_ctor<1>(); - test_val_ctor<31>(); - test_val_ctor<32>(); - test_val_ctor<33>(); - test_val_ctor<63>(); - test_val_ctor<64>(); - test_val_ctor<65>(); - test_val_ctor<1000>(); + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/all.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/all.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/all.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/all.pass.cpp @@ -15,7 +15,7 @@ #include "test_macros.h" template -void test_all() { +TEST_CONSTEXPR_CXX23 void test_all() { std::bitset v; v.reset(); assert(v.all() == (N == 0)); @@ -27,16 +27,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_all<0>(); + test_all<1>(); + test_all<31>(); + test_all<32>(); + test_all<33>(); + test_all<63>(); + test_all<64>(); + test_all<65>(); + test_all<1000>(); + + return true; +} + int main(int, char**) { - test_all<0>(); - test_all<1>(); - test_all<31>(); - test_all<32>(); - test_all<33>(); - test_all<63>(); - test_all<64>(); - test_all<65>(); - test_all<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/any.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/any.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/any.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/any.pass.cpp @@ -15,7 +15,7 @@ #include "test_macros.h" template -void test_any() { +TEST_CONSTEXPR_CXX23 void test_any() { std::bitset v; v.reset(); assert(v.any() == false); @@ -30,16 +30,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_any<0>(); + test_any<1>(); + test_any<31>(); + test_any<32>(); + test_any<33>(); + test_any<63>(); + test_any<64>(); + test_any<65>(); + test_any<1000>(); + + return true; +} + int main(int, char**) { - test_any<0>(); - test_any<1>(); - test_any<31>(); - test_any<32>(); - test_any<33>(); - test_any<63>(); - test_any<64>(); - test_any<65>(); - test_any<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/count.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/count.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/count.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/count.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_count() { +TEST_CONSTEXPR_CXX23 void test_count() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { const std::bitset v = cases[c]; @@ -30,16 +30,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_count<0>(); + test_count<1>(); + test_count<31>(); + test_count<32>(); + test_count<33>(); + test_count<63>(); + test_count<64>(); + test_count<65>(); + + return true; +} + int main(int, char**) { - test_count<0>(); - test_count<1>(); - test_count<31>(); - test_count<32>(); - test_count<33>(); - test_count<63>(); - test_count<64>(); - test_count<65>(); - test_count<1000>(); - - return 0; + test(); + test_count<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_flip_all() { +TEST_CONSTEXPR_CXX23 void test_flip_all() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset v1 = cases[c]; @@ -28,16 +28,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_flip_all<0>(); + test_flip_all<1>(); + test_flip_all<31>(); + test_flip_all<32>(); + test_flip_all<33>(); + test_flip_all<63>(); + test_flip_all<64>(); + test_flip_all<65>(); + + return true; +} + int main(int, char**) { - test_flip_all<0>(); - test_flip_all<1>(); - test_flip_all<31>(); - test_flip_all<32>(); - test_flip_all<33>(); - test_flip_all<63>(); - test_flip_all<64>(); - test_flip_all<65>(); - test_flip_all<1000>(); - - return 0; + test(); + test_flip_all<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_flip_one() { +TEST_CONSTEXPR_CXX23 void test_flip_one() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset v = cases[c]; @@ -34,16 +34,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_flip_one<0>(); + test_flip_one<1>(); + test_flip_one<31>(); + test_flip_one<32>(); + test_flip_one<33>(); + test_flip_one<63>(); + test_flip_one<64>(); + test_flip_one<65>(); + + return true; +} + int main(int, char**) { - test_flip_one<0>(); - test_flip_one<1>(); - test_flip_one<31>(); - test_flip_one<32>(); - test_flip_one<33>(); - test_flip_one<63>(); - test_flip_one<64>(); - test_flip_one<65>(); - test_flip_one<1000>(); - - return 0; + test(); + test_flip_one<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/index.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/index.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/index.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/index.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_index() { +TEST_CONSTEXPR_CXX23 void test_index() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset v1 = cases[c]; @@ -46,22 +46,31 @@ } } -int main(int, char**) { - test_index<0>(); - test_index<1>(); - test_index<31>(); - test_index<32>(); - test_index<33>(); - test_index<63>(); - test_index<64>(); - test_index<65>(); - test_index<1000>(); +TEST_CONSTEXPR_CXX23 bool test() { + test_index<0>(); + test_index<1>(); + test_index<31>(); + test_index<32>(); + test_index<33>(); + test_index<63>(); + test_index<64>(); + test_index<65>(); + + std::bitset<1> set; + set[0] = false; + auto b = set[0]; + set[0] = true; + assert(b); - std::bitset<1> set; - set[0] = false; - auto b = set[0]; - set[0] = true; - assert(b); + return true; +} + +int main(int, char**) { + test(); + test_index<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_index_const() { +TEST_CONSTEXPR_CXX23 void test_index_const() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset const v = cases[c]; @@ -32,16 +32,15 @@ #endif } -int main(int, char**) { - test_index_const<0>(); - test_index_const<1>(); - test_index_const<31>(); - test_index_const<32>(); - test_index_const<33>(); - test_index_const<63>(); - test_index_const<64>(); - test_index_const<65>(); - test_index_const<1000>(); +TEST_CONSTEXPR_CXX23 bool test() { + test_index_const<0>(); + test_index_const<1>(); + test_index_const<31>(); + test_index_const<32>(); + test_index_const<33>(); + test_index_const<63>(); + test_index_const<64>(); + test_index_const<65>(); std::bitset<1> set_; set_[0] = false; @@ -54,5 +53,15 @@ assert(b); #endif - return 0; + return true; +} + +int main(int, char**) { + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + test_index_const<1000>(); + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_left_shift() { +TEST_CONSTEXPR_CXX23 void test_left_shift() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { for (std::size_t s = 0; s <= N+1; ++s) { @@ -28,16 +28,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_left_shift<0>(); + test_left_shift<1>(); + test_left_shift<31>(); + test_left_shift<32>(); + test_left_shift<33>(); + test_left_shift<63>(); + test_left_shift<64>(); + test_left_shift<65>(); + + return true; +} + int main(int, char**) { - test_left_shift<0>(); - test_left_shift<1>(); - test_left_shift<31>(); - test_left_shift<32>(); - test_left_shift<33>(); - test_left_shift<63>(); - test_left_shift<64>(); - test_left_shift<65>(); - test_left_shift<1000>(); - - return 0; + test(); + test_left_shift<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_left_shift() { +TEST_CONSTEXPR_CXX23 bool test_left_shift() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { for (std::size_t s = 0; s <= N+1; ++s) { @@ -31,18 +31,29 @@ assert(v1[i] == v2[i-s]); } } + return true; } int main(int, char**) { - test_left_shift<0>(); - test_left_shift<1>(); - test_left_shift<31>(); - test_left_shift<32>(); - test_left_shift<33>(); - test_left_shift<63>(); - test_left_shift<64>(); - test_left_shift<65>(); - test_left_shift<1000>(); + test_left_shift<0>(); + test_left_shift<1>(); + test_left_shift<31>(); + test_left_shift<32>(); + test_left_shift<33>(); + test_left_shift<63>(); + test_left_shift<64>(); + test_left_shift<65>(); + test_left_shift<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test_left_shift<0>()); + static_assert(test_left_shift<1>()); + static_assert(test_left_shift<31>()); + static_assert(test_left_shift<32>()); + static_assert(test_left_shift<33>()); + static_assert(test_left_shift<63>()); + static_assert(test_left_shift<64>()); + static_assert(test_left_shift<65>()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/none.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/none.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/none.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/none.pass.cpp @@ -15,7 +15,7 @@ #include "test_macros.h" template -void test_none() { +TEST_CONSTEXPR_CXX23 void test_none() { std::bitset v; v.reset(); assert(v.none() == true); @@ -30,16 +30,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_none<0>(); + test_none<1>(); + test_none<31>(); + test_none<32>(); + test_none<33>(); + test_none<63>(); + test_none<64>(); + test_none<65>(); + test_none<1000>(); + + return true; +} + int main(int, char**) { - test_none<0>(); - test_none<1>(); - test_none<31>(); - test_none<32>(); - test_none<33>(); - test_none<63>(); - test_none<64>(); - test_none<65>(); - test_none<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_not_all() { +TEST_CONSTEXPR_CXX23 void test_not_all() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset v1 = cases[c]; @@ -27,16 +27,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_not_all<0>(); + test_not_all<1>(); + test_not_all<31>(); + test_not_all<32>(); + test_not_all<33>(); + test_not_all<63>(); + test_not_all<64>(); + test_not_all<65>(); + + return true; +} + int main(int, char**) { - test_not_all<0>(); - test_not_all<1>(); - test_not_all<31>(); - test_not_all<32>(); - test_not_all<33>(); - test_not_all<63>(); - test_not_all<64>(); - test_not_all<65>(); - test_not_all<1000>(); - - return 0; + test(); + test_not_all<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_and_eq() { +TEST_CONSTEXPR_CXX23 void test_op_and_eq() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -31,16 +31,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_op_and_eq<0>(); + test_op_and_eq<1>(); + test_op_and_eq<31>(); + test_op_and_eq<32>(); + test_op_and_eq<33>(); + test_op_and_eq<63>(); + test_op_and_eq<64>(); + test_op_and_eq<65>(); + + return true; +} + int main(int, char**) { - test_op_and_eq<0>(); - test_op_and_eq<1>(); - test_op_and_eq<31>(); - test_op_and_eq<32>(); - test_op_and_eq<33>(); - test_op_and_eq<63>(); - test_op_and_eq<64>(); - test_op_and_eq<65>(); - test_op_and_eq<1000>(); - - return 0; + test(); + test_op_and_eq<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp @@ -20,7 +20,7 @@ #include "test_macros.h" template -void test_equality() { +TEST_CONSTEXPR_CXX23 void test_equality() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset const v1 = cases[c]; @@ -33,16 +33,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_equality<0>(); + test_equality<1>(); + test_equality<31>(); + test_equality<32>(); + test_equality<33>(); + test_equality<63>(); + test_equality<64>(); + test_equality<65>(); + + return true; +} + int main(int, char**) { - test_equality<0>(); - test_equality<1>(); - test_equality<31>(); - test_equality<32>(); - test_equality<33>(); - test_equality<63>(); - test_equality<64>(); - test_equality<65>(); - test_equality<1000>(); - - return 0; + test(); + test_equality<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_or_eq() { +TEST_CONSTEXPR_CXX23 void test_op_or_eq() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -31,16 +31,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_op_or_eq<0>(); + test_op_or_eq<1>(); + test_op_or_eq<31>(); + test_op_or_eq<32>(); + test_op_or_eq<33>(); + test_op_or_eq<63>(); + test_op_or_eq<64>(); + test_op_or_eq<65>(); + + return true; +} + int main(int, char**) { - test_op_or_eq<0>(); - test_op_or_eq<1>(); - test_op_or_eq<31>(); - test_op_or_eq<32>(); - test_op_or_eq<33>(); - test_op_or_eq<63>(); - test_op_or_eq<64>(); - test_op_or_eq<65>(); - test_op_or_eq<1000>(); - - return 0; + test(); + test_op_or_eq<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_xor_eq() { +TEST_CONSTEXPR_CXX23 bool test_op_xor_eq() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -29,18 +29,29 @@ assert(v1[i] == (v3[i] != v2[i])); } } + return true; } int main(int, char**) { - test_op_xor_eq<0>(); - test_op_xor_eq<1>(); - test_op_xor_eq<31>(); - test_op_xor_eq<32>(); - test_op_xor_eq<33>(); - test_op_xor_eq<63>(); - test_op_xor_eq<64>(); - test_op_xor_eq<65>(); - test_op_xor_eq<1000>(); + test_op_xor_eq<0>(); + test_op_xor_eq<1>(); + test_op_xor_eq<31>(); + test_op_xor_eq<32>(); + test_op_xor_eq<33>(); + test_op_xor_eq<63>(); + test_op_xor_eq<64>(); + test_op_xor_eq<65>(); + test_op_xor_eq<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test_op_xor_eq<0>()); + static_assert(test_op_xor_eq<1>()); + static_assert(test_op_xor_eq<31>()); + static_assert(test_op_xor_eq<32>()); + static_assert(test_op_xor_eq<33>()); + static_assert(test_op_xor_eq<63>()); + static_assert(test_op_xor_eq<64>()); + static_assert(test_op_xor_eq<65>()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp @@ -15,7 +15,7 @@ #include "test_macros.h" template -void test_reset_all() { +TEST_CONSTEXPR_CXX23 void test_reset_all() { std::bitset v; v.set(); v.reset(); @@ -23,16 +23,25 @@ assert(!v[i]); } +TEST_CONSTEXPR_CXX23 bool test() { + test_reset_all<0>(); + test_reset_all<1>(); + test_reset_all<31>(); + test_reset_all<32>(); + test_reset_all<33>(); + test_reset_all<63>(); + test_reset_all<64>(); + test_reset_all<65>(); + test_reset_all<1000>(); + + return true; +} + int main(int, char**) { - test_reset_all<0>(); - test_reset_all<1>(); - test_reset_all<31>(); - test_reset_all<32>(); - test_reset_all<33>(); - test_reset_all<63>(); - test_reset_all<64>(); - test_reset_all<65>(); - test_reset_all<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp @@ -19,7 +19,7 @@ TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. template -void test_reset_one() { +TEST_CONSTEXPR_CXX23 void test_reset_one() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { for (std::size_t i = 0; i != N; ++i) { @@ -30,16 +30,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_reset_one<0>(); + test_reset_one<1>(); + test_reset_one<31>(); + test_reset_one<32>(); + test_reset_one<33>(); + test_reset_one<63>(); + test_reset_one<64>(); + test_reset_one<65>(); + + return true; +} + int main(int, char**) { - test_reset_one<0>(); - test_reset_one<1>(); - test_reset_one<31>(); - test_reset_one<32>(); - test_reset_one<33>(); - test_reset_one<63>(); - test_reset_one<64>(); - test_reset_one<65>(); - test_reset_one<1000>(); - - return 0; + test(); + test_reset_one<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_right_shift() { +TEST_CONSTEXPR_CXX23 bool test_right_shift() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { for (std::size_t s = 0; s <= N+1; ++s) { @@ -26,18 +26,29 @@ assert((v1 >>= s) == (v2 >> s)); } } + return true; } int main(int, char**) { - test_right_shift<0>(); - test_right_shift<1>(); - test_right_shift<31>(); - test_right_shift<32>(); - test_right_shift<33>(); - test_right_shift<63>(); - test_right_shift<64>(); - test_right_shift<65>(); - test_right_shift<1000>(); + test_right_shift<0>(); + test_right_shift<1>(); + test_right_shift<31>(); + test_right_shift<32>(); + test_right_shift<33>(); + test_right_shift<63>(); + test_right_shift<64>(); + test_right_shift<65>(); + test_right_shift<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test_right_shift<0>()); + static_assert(test_right_shift<1>()); + static_assert(test_right_shift<31>()); + static_assert(test_right_shift<32>()); + static_assert(test_right_shift<33>()); + static_assert(test_right_shift<63>()); + static_assert(test_right_shift<64>()); + static_assert(test_right_shift<65>()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_right_shift() { +TEST_CONSTEXPR_CXX23 bool test_right_shift() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { for (std::size_t s = 0; s <= N+1; ++s) { @@ -31,18 +31,34 @@ assert(v1[i] == 0); } } + return true; +} + +TEST_CONSTEXPR_CXX23 bool test() { + + return true; } int main(int, char**) { - test_right_shift<0>(); - test_right_shift<1>(); - test_right_shift<31>(); - test_right_shift<32>(); - test_right_shift<33>(); - test_right_shift<63>(); - test_right_shift<64>(); - test_right_shift<65>(); - test_right_shift<1000>(); - - return 0; + test_right_shift<0>(); + test_right_shift<1>(); + test_right_shift<31>(); + test_right_shift<32>(); + test_right_shift<33>(); + test_right_shift<63>(); + test_right_shift<64>(); + test_right_shift<65>(); + test_right_shift<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test_right_shift<0>()); + static_assert(test_right_shift<1>()); + static_assert(test_right_shift<31>()); + static_assert(test_right_shift<32>()); + static_assert(test_right_shift<33>()); + static_assert(test_right_shift<63>()); + static_assert(test_right_shift<64>()); + static_assert(test_right_shift<65>()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp @@ -15,23 +15,32 @@ #include "test_macros.h" template -void test_set_all() { +TEST_CONSTEXPR_CXX23 void test_set_all() { std::bitset v; v.set(); for (std::size_t i = 0; i < v.size(); ++i) assert(v[i]); } +TEST_CONSTEXPR_CXX23 bool test() { + test_set_all<0>(); + test_set_all<1>(); + test_set_all<31>(); + test_set_all<32>(); + test_set_all<33>(); + test_set_all<63>(); + test_set_all<64>(); + test_set_all<65>(); + test_set_all<1000>(); + + return true; +} + int main(int, char**) { - test_set_all<0>(); - test_set_all<1>(); - test_set_all<31>(); - test_set_all<32>(); - test_set_all<33>(); - test_set_all<63>(); - test_set_all<64>(); - test_set_all<65>(); - test_set_all<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_set_one() { +TEST_CONSTEXPR_CXX23 void test_set_one() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset v = cases[c]; @@ -31,16 +31,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_set_one<0>(); + test_set_one<1>(); + test_set_one<31>(); + test_set_one<32>(); + test_set_one<33>(); + test_set_one<63>(); + test_set_one<64>(); + test_set_one<65>(); + + return true; +} + int main(int, char**) { - test_set_one<0>(); - test_set_one<1>(); - test_set_one<31>(); - test_set_one<32>(); - test_set_one<33>(); - test_set_one<63>(); - test_set_one<64>(); - test_set_one<65>(); - test_set_one<1000>(); - - return 0; + test(); + test_set_one<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/size.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/size.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/size.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/size.pass.cpp @@ -14,21 +14,30 @@ #include "test_macros.h" template -void test_size() { +TEST_CONSTEXPR_CXX23 void test_size() { const std::bitset v; assert(v.size() == N); } +TEST_CONSTEXPR_CXX23 bool test() { + test_size<0>(); + test_size<1>(); + test_size<31>(); + test_size<32>(); + test_size<33>(); + test_size<63>(); + test_size<64>(); + test_size<65>(); + test_size<1000>(); + + return true; +} + int main(int, char**) { - test_size<0>(); - test_size<1>(); - test_size<31>(); - test_size<32>(); - test_size<33>(); - test_size<63>(); - test_size<64>(); - test_size<65>(); - test_size<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_test() { +TEST_CONSTEXPR_CXX23 void test_test() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset const v = cases[c]; @@ -29,16 +29,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_test<0>(); + test_test<1>(); + test_test<31>(); + test_test<32>(); + test_test<33>(); + test_test<63>(); + test_test<64>(); + test_test<65>(); + + return true; +} + int main(int, char**) { - test_test<0>(); - test_test<1>(); - test_test<31>(); - test_test<32>(); - test_test<33>(); - test_test<63>(); - test_test<64>(); - test_test<65>(); - test_test<1000>(); - - return 0; + test(); + test_test<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp @@ -31,7 +31,7 @@ #include "test_macros.h" template -void check_equal(std::basic_string const& s, std::bitset const& b, CharT zero, CharT one) { +TEST_CONSTEXPR_CXX23 void check_equal(std::basic_string const& s, std::bitset const& b, CharT zero, CharT one) { assert(s.size() == b.size()); for (std::size_t i = 0; i < b.size(); ++i) { if (b[i]) { @@ -43,7 +43,7 @@ } template -void test_to_string() { +TEST_CONSTEXPR_CXX23 bool test_to_string() { std::vector > const cases = get_test_cases(); for (std::size_t c = 0; c != cases.size(); ++c) { std::bitset const v = cases[c]; @@ -106,18 +106,29 @@ check_equal(s, v, 'x', 'y'); } } + return true; } int main(int, char**) { - test_to_string<0>(); - test_to_string<1>(); - test_to_string<31>(); - test_to_string<32>(); - test_to_string<33>(); - test_to_string<63>(); - test_to_string<64>(); - test_to_string<65>(); - test_to_string<1000>(); + test_to_string<0>(); + test_to_string<1>(); + test_to_string<31>(); + test_to_string<32>(); + test_to_string<33>(); + test_to_string<63>(); + test_to_string<64>(); + test_to_string<65>(); + test_to_string<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test_to_string<0>()); + static_assert(test_to_string<1>()); + static_assert(test_to_string<31>()); + static_assert(test_to_string<32>()); + static_assert(test_to_string<33>()); + static_assert(test_to_string<63>()); + static_assert(test_to_string<64>()); + static_assert(test_to_string<65>()); +#endif - return 0; + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_to_ullong() { +TEST_CONSTEXPR_CXX23 void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; const bool is_M_zero = std::integral_constant::value; // avoid compiler warnings const std::size_t X = is_M_zero ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; @@ -32,9 +32,8 @@ std::min(max, max-1), max }; - for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { - unsigned long long j = tests[i]; - std::bitset v(j); + for (unsigned long long j : tests) { + std::bitset v(j); assert(j == v.to_ullong()); } { // test values bigger than can fit into the bitset @@ -46,16 +45,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_to_ullong<0>(); + test_to_ullong<1>(); + test_to_ullong<31>(); + test_to_ullong<32>(); + test_to_ullong<33>(); + test_to_ullong<63>(); + test_to_ullong<64>(); + test_to_ullong<65>(); + test_to_ullong<1000>(); + + return true; +} + int main(int, char**) { -// test_to_ullong<0>(); - test_to_ullong<1>(); - test_to_ullong<31>(); - test_to_ullong<32>(); - test_to_ullong<33>(); - test_to_ullong<63>(); - test_to_ullong<64>(); - test_to_ullong<65>(); - test_to_ullong<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" template -void test_to_ulong() { +TEST_CONSTEXPR_CXX23 void test_to_ulong() { const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N; const bool is_M_zero = std::integral_constant::value; // avoid compiler warnings const std::size_t X = is_M_zero ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; @@ -33,9 +33,8 @@ std::min(max, max-1), max }; - for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { - std::size_t j = tests[i]; - std::bitset v(j); + for (unsigned long j : tests) { + std::bitset v(j); assert(j == v.to_ulong()); } @@ -48,16 +47,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_to_ulong<0>(); + test_to_ulong<1>(); + test_to_ulong<31>(); + test_to_ulong<32>(); + test_to_ulong<33>(); + test_to_ulong<63>(); + test_to_ulong<64>(); + test_to_ulong<65>(); + test_to_ulong<1000>(); + + return true; +} + int main(int, char**) { - test_to_ulong<0>(); - test_to_ulong<1>(); - test_to_ulong<31>(); - test_to_ulong<32>(); - test_to_ulong<33>(); - test_to_ulong<63>(); - test_to_ulong<64>(); - test_to_ulong<65>(); - test_to_ulong<1000>(); - - return 0; + test(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_and() { +TEST_CONSTEXPR_CXX23 void test_op_and() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -29,16 +29,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_op_and<0>(); + test_op_and<1>(); + test_op_and<31>(); + test_op_and<32>(); + test_op_and<33>(); + test_op_and<63>(); + test_op_and<64>(); + test_op_and<65>(); + + return true; +} + int main(int, char**) { - test_op_and<0>(); - test_op_and<1>(); - test_op_and<31>(); - test_op_and<32>(); - test_op_and<33>(); - test_op_and<63>(); - test_op_and<64>(); - test_op_and<65>(); - test_op_and<1000>(); - - return 0; + test(); + test_op_and<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_not() { +TEST_CONSTEXPR_CXX23 void test_op_not() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -29,16 +29,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_op_not<0>(); + test_op_not<1>(); + test_op_not<31>(); + test_op_not<32>(); + test_op_not<33>(); + test_op_not<63>(); + test_op_not<64>(); + test_op_not<65>(); + + return true; +} + int main(int, char**) { - test_op_not<0>(); - test_op_not<1>(); - test_op_not<31>(); - test_op_not<32>(); - test_op_not<33>(); - test_op_not<63>(); - test_op_not<64>(); - test_op_not<65>(); - test_op_not<1000>(); - - return 0; + test(); + test_op_not<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp @@ -17,7 +17,7 @@ #include "test_macros.h" template -void test_op_or() { +TEST_CONSTEXPR_CXX23 void test_op_or() { std::vector > const cases = get_test_cases(); for (std::size_t c1 = 0; c1 != cases.size(); ++c1) { for (std::size_t c2 = 0; c2 != cases.size(); ++c2) { @@ -29,16 +29,25 @@ } } +TEST_CONSTEXPR_CXX23 bool test() { + test_op_or<0>(); + test_op_or<1>(); + test_op_or<31>(); + test_op_or<32>(); + test_op_or<33>(); + test_op_or<63>(); + test_op_or<64>(); + test_op_or<65>(); + + return true; +} + int main(int, char**) { - test_op_or<0>(); - test_op_or<1>(); - test_op_or<31>(); - test_op_or<32>(); - test_op_or<33>(); - test_op_or<63>(); - test_op_or<64>(); - test_op_or<65>(); - test_op_or<1000>(); - - return 0; + test(); + test_op_or<1000>(); +#if TEST_STD_VER >= 23 + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/utilities/template.bitset/bitset_test_cases.h b/libcxx/test/std/utilities/template.bitset/bitset_test_cases.h --- a/libcxx/test/std/utilities/template.bitset/bitset_test_cases.h +++ b/libcxx/test/std/utilities/template.bitset/bitset_test_cases.h @@ -12,18 +12,20 @@ #include #include +#include "test_macros.h" + template -std::vector > get_test_cases(); +TEST_CONSTEXPR_CXX23 std::vector > get_test_cases(); template <> -inline std::vector > get_test_cases<0>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<0>() { std::vector > cases; cases.push_back(std::bitset<0>()); return cases; } template <> -inline std::vector > get_test_cases<1>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<1>() { std::vector > cases; cases.push_back(std::bitset<1>("0")); cases.push_back(std::bitset<1>("1")); @@ -31,7 +33,7 @@ } template <> -inline std::vector > get_test_cases<2>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<2>() { std::vector > cases; cases.push_back(std::bitset<2>("00")); cases.push_back(std::bitset<2>("01")); @@ -41,7 +43,7 @@ } template <> -inline std::vector > get_test_cases<31>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<31>() { std::vector > cases; cases.push_back(std::bitset<31>("0000000000000000000000000000000")); cases.push_back(std::bitset<31>("0000000000000000000000000000001")); @@ -59,7 +61,7 @@ } template <> -inline std::vector > get_test_cases<32>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<32>() { std::vector > cases; cases.push_back(std::bitset<32>("00000000000000000000000000000000")); cases.push_back(std::bitset<32>("00000000000000000000000000000001")); @@ -77,7 +79,7 @@ } template <> -inline std::vector > get_test_cases<33>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<33>() { std::vector > cases; cases.push_back(std::bitset<33>("000000000000000000000000000000000")); cases.push_back(std::bitset<33>("000000000000000000000000000000001")); @@ -95,7 +97,7 @@ } template <> -inline std::vector > get_test_cases<63>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<63>() { std::vector > cases; cases.push_back(std::bitset<63>("000000000000000000000000000000000000000000000000000000000000000")); cases.push_back(std::bitset<63>("000000000000000000000000000000000000000000000000000000000000001")); @@ -113,7 +115,7 @@ } template <> -inline std::vector > get_test_cases<64>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<64>() { std::vector > cases; cases.push_back(std::bitset<64>("0000000000000000000000000000000000000000000000000000000000000000")); cases.push_back(std::bitset<64>("0000000000000000000000000000000000000000000000000000000000000001")); @@ -131,7 +133,7 @@ } template <> -inline std::vector > get_test_cases<65>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<65>() { std::vector > cases; cases.push_back(std::bitset<65>("00000000000000000000000000000000000000000000000000000000000000000")); cases.push_back(std::bitset<65>("00000000000000000000000000000000000000000000000000000000000000001")); @@ -148,7 +150,7 @@ return cases; } -inline std::string str_repeat(std::string s, unsigned int n) { +TEST_CONSTEXPR_CXX23 inline std::string str_repeat(std::string s, unsigned int n) { std::string res = s; for (; n != 0; --n) res += s; @@ -156,7 +158,7 @@ } template <> -inline std::vector > get_test_cases<1000>() { +TEST_CONSTEXPR_CXX23 inline std::vector > get_test_cases<1000>() { std::vector > cases; cases.push_back(std::bitset<1000>(std::string(1000, '0'))); cases.push_back(std::bitset<1000>(std::string(999, '0') + std::string(1, '1'))); diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -166,6 +166,12 @@ # define TEST_CONSTEXPR_CXX20 #endif +#if TEST_STD_VER >= 23 +# define TEST_CONSTEXPR_CXX23 constexpr +#else +# define TEST_CONSTEXPR_CXX23 constexpr +#endif + #define TEST_ALIGNAS_TYPE(...) TEST_ALIGNAS(TEST_ALIGNOF(__VA_ARGS__)) #if !TEST_HAS_FEATURE(cxx_rtti) && !defined(__cpp_rtti) \ diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -214,6 +214,10 @@ "name": "__cpp_lib_constexpr_algorithms", "values": { "c++20": 201806 }, "headers": ["algorithm"], + }, { + "name": "__cpp_lib_constexpr_bitset", + "values": { "c++2b": 202207 }, + "headers": ["bitset"], }, { "name": "__cpp_lib_constexpr_cmath", "values": { "c++2b": 202202 },