diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index d256af40f40..e5dc04f0840 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -106,6 +106,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } +#if __cplusplus > 202002L + constexpr const _Bit_reference& + operator=(bool __x) const noexcept + { + if (__x) + *_M_p |= _M_mask; + else + *_M_p &= ~_M_mask; + return *this; + } +#endif // C++23 + _GLIBCXX20_CONSTEXPR _Bit_reference& operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 831e770d54b..bffca0daf65 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -212,6 +212,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION swap(second, __p.second); } +#if __cplusplus > 202002L + constexpr void + swap(const pair& __p) const + noexcept(__and_v<__is_nothrow_swappable, + __is_nothrow_swappable>) + { + using std::swap; + swap(first, __p.first); + swap(second, __p.second); + } +#endif // C++23 + private: template @@ -283,7 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } - /// Converting constructor from a `pair` lvalue + /// Converting constructor from a const `pair` lvalue template requires (_S_constructible()) constexpr explicit(!_S_convertible()) @@ -292,7 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : first(__p.first), second(__p.second) { } - /// Converting constructor from a `pair` rvalue + /// Converting constructor from a non-const `pair` rvalue template requires (_S_constructible<_U1, _U2>()) constexpr explicit(!_S_convertible<_U1, _U2>()) @@ -302,6 +314,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION second(std::forward<_U2>(__p.second)) { } +#if __cplusplus > 202002L + /// Converting constructor from a non-const `pair` lvalue + template + requires (_S_constructible<_U1&, _U2&>()) + constexpr explicit(!_S_convertible<_U1&, _U2&>()) + pair(pair<_U1, _U2>& __p) + noexcept(_S_nothrow_constructible<_U1&, _U2&>()) + : first(__p.first), second(__p.second) + { } + + /// Converting constructor from a const `pair` rvalue + template + requires (_S_constructible()) + constexpr explicit(!_S_convertible()) + pair(const pair<_U1, _U2>&& __p) + noexcept(_S_nothrow_constructible()) + : first(std::forward(__p.first)), + second(std::forward(__p.second)) + { } +#endif // C++23 + private: /// @cond undocumented template @@ -349,7 +382,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } - /// Converting assignment from a `pair` lvalue + /// Converting assignment from a const `pair` lvalue template constexpr pair& operator=(const pair<_U1, _U2>& __p) @@ -361,7 +394,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } - /// Converting assignment from a `pair` rvalue + /// Converting assignment from a non-const `pair` rvalue template constexpr pair& operator=(pair<_U1, _U2>&& __p) @@ -372,7 +405,55 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION second = std::forward<_U2>(__p.second); return *this; } -#else + +#if __cplusplus > 202002L + /// Copy assignment operator (const) + constexpr const pair& + operator=(const pair& __p) const + requires is_copy_assignable_v + && is_copy_assignable_v + { + first = __p.first; + second = __p.second; + return *this; + } + + /// Move assignment operator (const) + constexpr const pair& + operator=(pair&& __p) const + requires is_assignable_v + && is_assignable_v + { + first = std::forward(__p.first); + second = std::forward(__p.second); + return *this; + } + + /// Converting assignment from a const `pair` lvalue + template + constexpr const pair& + operator=(const pair<_U1, _U2>& __p) const + requires is_assignable_v + && is_assignable_v + { + first = __p.first; + second = __p.second; + return *this; + } + + /// Converting assignment from a non-const `pair` rvalue + template + constexpr const pair& + operator=(pair<_U1, _U2>&& __p) const + requires is_assignable_v + && is_assignable_v + { + first = std::forward<_U1>(__p.first); + second = std::forward<_U2>(__p.second); + return *this; + } +#endif // C++23 +#else // !__cpp_lib_concepts // C++11/14/17 implementation using enable_if, partially constexpr. /** The default constructor creates @c first and @c second using their @@ -710,6 +791,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } +#if __cplusplus > 202002L + template + requires is_swappable_v && is_swappable_v + constexpr void + swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } +#endif // C++23 + #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template typename enable_if, @@ -918,6 +1008,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION get(const pair<_Up, _Tp>&& __p) noexcept { return std::move(__p.second); } +#if __cplusplus > 202002L + template class _TQual, template class _UQual> + requires requires { typename pair, _UQual<_U1>>, + common_reference_t<_TQual<_T2>, _UQual<_U2>>>; } + struct basic_common_reference, pair<_U1, _U2>, _TQual, _UQual> + { + using type = pair, _UQual<_U1>>, + common_reference_t<_TQual<_T2>, _UQual<_U2>>>; + }; + + template + requires requires { typename pair, common_type_t<_T2, _U2>>; } + struct common_type, pair<_U1, _U2>> + { using type = pair, common_type_t<_T2, _U2>>; }; +#endif // C++23 + #endif // C++14 /// @} #endif // C++11 diff --git a/libstdc++-v3/include/bits/uses_allocator_args.h b/libstdc++-v3/include/bits/uses_allocator_args.h index 09cdbf1aaa8..ef5c4fffb70 100644 --- a/libstdc++-v3/include/bits/uses_allocator_args.h +++ b/libstdc++-v3/include/bits/uses_allocator_args.h @@ -107,6 +107,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr auto uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept; +#if __cplusplus > 202002L + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, + pair<_Up, _Vp>&) noexcept; + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, const pair<_Up, _Vp>&&) noexcept; +#endif // C++23 + template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2> constexpr auto uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, @@ -181,6 +192,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::move(__pr).second)); } +#if __cplusplus > 202002L + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + pair<_Up, _Vp>& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, __pr.first), + std::uses_allocator_construction_args<_Tp2>(__a, __pr.second)); + } + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + const pair<_Up, _Vp>&& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, + std::move(__pr).first), + std::uses_allocator_construction_args<_Tp2>(__a, + std::move(__pr).second)); + } +#endif // C++23 + template constexpr _Tp make_obj_using_allocator(const _Alloc& __a, _Args&&... __args) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 7f9c07248d4..05433d5ae36 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -316,6 +316,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } +#if __cplusplus > 202002L + template + constexpr + _Tuple_impl(_Tuple_impl<_Idx, _UElements...>& __in) + : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)), + _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(const _Tuple_impl<_Idx, _UHead, _UTails...>&& __in) + : _Inherited(std::move + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), + _Base(std::forward + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) + { } +#endif // C++23 + template _GLIBCXX20_CONSTEXPR _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) @@ -379,6 +397,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } +#if __cplusplus > 202002L + template + constexpr + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl<_Idx, _UHead, _UTails...>& __in) + : _Inherited(__tag, __a, + _Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)), + _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a), + _Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl<_Idx, _UHead, _UTails...>&& __in) + : _Inherited(__tag, __a, std::move + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), + _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a), + std::forward + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) + { } +#endif // C++23 + template _GLIBCXX20_CONSTEXPR void @@ -400,6 +441,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))); } +#if __cplusplus > 202002L + template + constexpr void + _M_assign(const _Tuple_impl<_Idx, _UElements...>& __in) const + { + _M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in); + _M_tail(*this)._M_assign( + _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)); + } + + template + constexpr void + _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) const + { + _M_head(*this) = std::forward<_UHead> + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)); + _M_tail(*this)._M_assign( + std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))); + } +#endif // C++23 + protected: _GLIBCXX20_CONSTEXPR void @@ -409,6 +471,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION swap(_M_head(*this), _M_head(__in)); _Inherited::_M_swap(_M_tail(__in)); } + +#if __cplusplus > 202002L + constexpr void + _M_swap(const _Tuple_impl& __in) const + { + using std::swap; + swap(_M_head(*this), _M_head(__in)); + _Inherited::_M_swap(_M_tail(__in)); + } +#endif // C++23 }; // Basis case of inheritance recursion. @@ -469,6 +541,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Base(std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) { } +#if __cplusplus > 202002L + template + constexpr + _Tuple_impl(_Tuple_impl<_Idx, _UHead>& __in) + : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(const _Tuple_impl<_Idx, _UHead>&& __in) + : _Base(std::forward(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) + { } +#endif // C++23 + template _GLIBCXX20_CONSTEXPR _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) @@ -521,6 +607,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) { } +#if __cplusplus > 202002L + template + constexpr + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl<_Idx, _UHead>& __in) + : _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a), + _Tuple_impl<_Idx, _UHead>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl<_Idx, _UHead>&& __in) + : _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a), + std::forward(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) + { } +#endif // C++23 + template _GLIBCXX20_CONSTEXPR void @@ -538,6 +642,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)); } +#if __cplusplus > 202002L + template + constexpr void + _M_assign(const _Tuple_impl<_Idx, _UHead>& __in) const + { + _M_head(*this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in); + } + + template + constexpr void + _M_assign(_Tuple_impl<_Idx, _UHead>&& __in) const + { + _M_head(*this) + = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)); + } +#endif // C++23 + protected: _GLIBCXX20_CONSTEXPR void @@ -546,6 +667,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::swap; swap(_M_head(*this), _M_head(__in)); } + +#if __cplusplus > 202002L + constexpr void + _M_swap(const _Tuple_impl& __in) const + { + using std::swap; + swap(_M_head(*this), _M_head(__in)); + } +#endif // C++23 }; // Concept utility functions, reused in conditionally-explicit @@ -712,6 +842,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool __use_other_ctor() { return _UseOtherCtor<_Tuple>::value; } +#if __cplusplus > 202002L + template + static constexpr bool __constructible + = _TCC::template __constructible<_Args...>::value; + + template + static constexpr bool __convertible + = _TCC::template __convertible<_Args...>::value; +#endif // C++23 + public: template::value> = true> @@ -799,6 +939,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } +#if __cplusplus > 202002L + template + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (!__use_other_ctor&>()) + && __constructible<_UElements&...> + explicit(!__convertible<_UElements&...>) + constexpr + tuple(tuple<_UElements...>& __in) + noexcept(__nothrow_constructible<_UElements&...>()) + : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&>(__in)) + { } + + template + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (!__use_other_ctor&&>()) + && __constructible + explicit(!__convertible) + constexpr + tuple(const tuple<_UElements...>&& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&&>(__in)) { } +#endif // C++23 + // Allocator-extended constructors. template&&>(__in)) { } +#if __cplusplus > 202002L + template + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (!__use_other_ctor&>()) + && __constructible<_UElements&...> + explicit(!__convertible<_UElements&...>) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, + tuple<_UElements...>& __in) + : _Inherited(__tag, __a, + static_cast<_Tuple_impl<0, _UElements...>&>(__in)) + { } + + template + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (!__use_other_ctor>()) + && __constructible + explicit(!__convertible) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_UElements...>&& __in) + : _Inherited(__tag, __a, + static_cast&&>(__in)) + { } +#endif // C++23 + // tuple assignment _GLIBCXX20_CONSTEXPR @@ -941,12 +1130,57 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } +#if __cplusplus > 202002L + constexpr const tuple& + operator=(const tuple& __in) const + requires (is_copy_assignable_v && ...) + { + this->_M_assign(__in); + return *this; + } + + constexpr const tuple& + operator=(tuple&& __in) const + requires (is_assignable_v && ...) + { + this->_M_assign(std::move(__in)); + return *this; + } + + template + constexpr const tuple& + operator=(const tuple<_UElements...>& __in) const + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (is_assignable_v && ...) + { + this->_M_assign(__in); + return *this; + } + + template + constexpr const tuple& + operator=(tuple<_UElements...>&& __in) const + requires (sizeof...(_Elements) == sizeof...(_UElements)) + && (is_assignable_v && ...) + { + this->_M_assign(std::move(__in)); + return *this; + } +#endif // C++23 + // tuple swap _GLIBCXX20_CONSTEXPR void swap(tuple& __in) noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value) { _Inherited::_M_swap(__in); } + +#if __cplusplus > 202002L + constexpr void + swap(const tuple& __in) const + noexcept(__and_v<__is_nothrow_swappable...>) + { _Inherited::_M_swap(__in); } +#endif // C++23 }; #if __cpp_deduction_guides >= 201606 @@ -969,6 +1203,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: _GLIBCXX20_CONSTEXPR void swap(tuple&) noexcept { /* no-op */ } +#if __cplusplus > 202002L + constexpr void swap(const tuple&) const noexcept { /* no-op */ } +#endif // We need the default since we're going to define no-op // allocator constructors. tuple() = default; @@ -1048,6 +1285,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool __is_alloc_arg() { return is_same<__remove_cvref_t<_U1>, allocator_arg_t>::value; } +#if __cplusplus > 202002L + template + static constexpr bool __constructible + = _TCC::template __constructible<_U1, _U2>::value; + + template + static constexpr bool __convertible + = _TCC::template __convertible<_U1, _U2>::value; +#endif // C++23 + public: template = true> @@ -1123,6 +1370,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } +#if __cplusplus > 202002L + template + requires __constructible<_U1&, _U2&> + explicit(!__convertible<_U1&, _U2&>) + constexpr + tuple(tuple<_U1, _U2>& __in) + noexcept(__nothrow_constructible<_U1&, _U2&>()) + : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&>(__in)) { } + + template + requires __constructible + explicit(!__convertible) + constexpr + tuple(const tuple<_U1, _U2>&& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&&>(__in)) { } +#endif // C++23 + template = true> constexpr @@ -1153,6 +1418,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Inherited(std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } +#if __cplusplus > 202002L + template + requires __constructible<_U1&, _U2&> + explicit(!__convertible<_U1&, _U2&>) + constexpr + tuple(pair<_U1, _U2>& __in) + noexcept(__nothrow_constructible<_U1&, _U2&>()) + : _Inherited(__in.first, __in.second) { } + + template + requires __constructible + explicit(!__convertible) + constexpr + tuple(const pair<_U1, _U2>&& __in) + noexcept(__nothrow_constructible()) + : _Inherited(std::forward(__in.first), + std::forward(__in.second)) { } +#endif // C++23 + // Allocator-extended constructors. template&&>(__in)) { } +#if __cplusplus > 202002L + template + requires __constructible<_U1&, _U2&> + explicit(!__convertible<_U1&, _U2&>) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, + tuple<_U1, _U2>& __in) + : _Inherited(__tag, __a, + static_cast<_Tuple_impl<0, _U1, _U2>&>(__in)) + { } + + template + requires __constructible + explicit(!__convertible) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_U1, _U2>&& __in) + : _Inherited(__tag, __a, + static_cast&&>(__in)) + { } +#endif // C++23 + template = true> _GLIBCXX20_CONSTEXPR @@ -1266,6 +1572,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Inherited(__tag, __a, std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } +#if __cplusplus > 202002L + template + requires __constructible<_U1&, _U2&> + explicit(!__convertible<_U1&, _U2&>) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, + pair<_U1, _U2>& __in) + : _Inherited(__tag, __a, __in.first, __in.second) { } + + template + requires __constructible + explicit(!__convertible) + constexpr + tuple(allocator_arg_t __tag, const _Alloc& __a, const pair<_U1, _U2>&& __in) + : _Inherited(__tag, __a, std::forward(__in.first), + std::forward(__in.second)) { } +#endif // C++23 + // Tuple assignment. _GLIBCXX20_CONSTEXPR @@ -1310,6 +1634,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } +#if __cplusplus > 202002L + constexpr const tuple& + operator=(const tuple& __in) const + requires is_copy_assignable_v && is_copy_assignable_v + { + this->_M_assign(__in); + return *this; + } + + constexpr const tuple& + operator=(tuple&& __in) const + requires is_assignable_v && is_assignable_v + { + this->_M_assign(std::move(__in)); + return *this; + } + + template + constexpr const tuple& + operator=(const tuple<_U1, _U2>& __in) const + requires is_assignable_v + && is_assignable_v + { + this->_M_assign(__in); + return *this; + } + + template + constexpr const tuple& + operator=(tuple<_U1, _U2>&& __in) const + requires is_assignable_v + && is_assignable_v + { + this->_M_assign(std::move(__in)); + return *this; + } +#endif // C++23 + template _GLIBCXX20_CONSTEXPR __enable_if_t<__assignable(), tuple&> @@ -1332,12 +1694,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } +#if __cplusplus > 202002L + template + constexpr const tuple& + operator=(const pair<_U1, _U2>& __in) const + requires is_assignable_v + && is_assignable_v + { + this->_M_head(*this) = __in.first; + this->_M_tail(*this)._M_head(*this) = __in.second; + return *this; + } + + template + constexpr const tuple& + operator=(pair<_U1, _U2>&& __in) const + requires is_assignable_v + && is_assignable_v + { + this->_M_head(*this) = std::forward<_U1>(__in.first); + this->_M_tail(*this)._M_head(*this) = std::forward<_U2>(__in.second); + return *this; + } +#endif // C++23 + _GLIBCXX20_CONSTEXPR void swap(tuple& __in) noexcept(__and_<__is_nothrow_swappable<_T1>, __is_nothrow_swappable<_T2>>::value) { _Inherited::_M_swap(__in); } + +#if __cplusplus > 202002L + constexpr void + swap(const tuple& __in) const + noexcept(__and_v<__is_nothrow_swappable, + __is_nothrow_swappable>) + { _Inherited::_M_swap(__in); } +#endif // C++23 }; @@ -1765,6 +2159,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } +#if __cplusplus > 202002L + template + requires (is_swappable_v && ...) + constexpr void + swap(const tuple<_Elements...>& __x, const tuple<_Elements...>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } +#endif // C++23 + #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template _GLIBCXX20_CONSTEXPR @@ -1889,6 +2292,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif // C++17 +#if __cplusplus > 202002L + template class TQual, template class UQual> + requires requires { typename tuple, UQual<_UTypes>>...>; } + struct basic_common_reference, tuple<_UTypes...>, TQual, UQual> + { using type = tuple, UQual<_UTypes>>...>; }; + + template + requires requires { typename tuple...>; } + struct common_type, tuple<_UTypes...>> + { using type = tuple...>; }; +#endif // C++23 + /// @} _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/20_util/pair/p2321r2.cc b/libstdc++-v3/testsuite/20_util/pair/p2321r2.cc new file mode 100644 index 00000000000..4f436ee03d6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/p2321r2.cc @@ -0,0 +1,208 @@ +// Verify P2321R2 "zip" enhancements to std::pair. +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++23 } } + +#include +#include + +using std::pair; + +struct A { }; + +constexpr bool +test01() +{ + struct B { bool v; constexpr B(A&) : v(true) { } }; + + // template + // constexpr explicit(false) pair(pair&); + + pair p2a0; + pair p2b0 = p2a0; + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + pair p2b1 = p2a1; + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +constexpr bool +test02() +{ + struct B { bool v; explicit constexpr B(A&) : v(true) { } }; + + // template + // constexpr explicit(true) pair(pair&); + + static_assert(!std::is_convertible_v&, pair>); + static_assert(!std::is_convertible_v&, pair>); + + pair p2a0; + pair p2b0(p2a0); + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + pair p2b1(p2a1); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +constexpr bool +test03() +{ + struct B { bool v; constexpr B(const A&&) : v(true) { } }; + + // template + // constexpr explicit(false) pair(const pair&&); + + const pair p2a0; + pair p2b0 = std::move(p2a0); + VERIFY( std::get<0>(p2b0).v ); + + const pair p2a1; + pair p2b1 = std::move(p2a1); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +constexpr bool +test04() +{ + struct B { bool v; explicit constexpr B(const A&&) : v(true) { } }; + + // template + // constexpr explicit(true) pair(const pair&&); + + static_assert(!std::is_convertible_v&&, pair>); + static_assert(!std::is_convertible_v&&, pair>); + + const pair p2a0; + pair p2b0(std::move(p2a0)); + VERIFY( std::get<0>(p2b0).v ); + + const pair p2a1; + pair p2b1(std::move(p2a1)); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +constexpr bool +test05() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(const A&) const { v = true; return *this; } + }; + + // template + // constexpr const pair& operator=(const pair&) const; + + const pair p2a; + const pair p2b; + p2b = p2a; + + return true; +} + +constexpr bool +test06() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(A&&) const { v = true; return *this; } + }; + + // template + // constexpr const pair& operator=(pair&&) const; + + pair p2a; + const pair p2b; + p2b = std::move(p2a); + + return true; +} + +constexpr bool +test07() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(const B&) const { v = true; return *this; } + }; + + // constexpr const pair& operator=(const pair&) const; + + const pair t2a; + const pair t2b; + t2b = t2a; + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + return true; +} + +constexpr bool +test08() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(B&&) const { v = true; return *this; } + }; + + // constexpr const pair& operator=(pair&&) const; + + pair t2a; + const pair t2b; + t2b = std::move(t2a); + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + return true; +} + +struct S +{ + mutable int v = 0; + friend constexpr void swap(S&& x, S&& y) = delete; + friend constexpr void swap(const S& x, const S& y) { ++x.v; ++y.v; } +}; + +constexpr bool +test09() +{ + const pair t2, u2; + std::swap(t2, u2); + VERIFY( std::get<0>(t2).v == 1 ); + VERIFY( std::get<0>(u2).v == 1 ); + VERIFY( std::get<1>(t2).v == 1 ); + VERIFY( std::get<1>(u2).v == 1 ); + + static_assert(!std::is_swappable_v&>); + static_assert(!std::is_swappable_v&>); + + return true; +} + +int +main() +{ + static_assert(test01()); + static_assert(test02()); + static_assert(test03()); + static_assert(test04()); + // FIXME: G++ doesn't support reading mutable members during constexpr (PR c++/92505). + test05(); + test06(); + test07(); + test08(); + test09(); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc new file mode 100644 index 00000000000..80fc23cf9d4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc @@ -0,0 +1,664 @@ +// Verify P2321R2 "zip" enhancements to std::tuple. +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++23 } } + +#include +#include +#include + +using std::tuple; +using std::pair; +using std::allocator; +using std::allocator_arg_t; +using std::allocator_arg; + +namespace alloc { + struct B01; + struct B02; + struct B03; + struct B04; +} + +template<> struct std::uses_allocator> : std::true_type { }; +template<> struct std::uses_allocator> : std::true_type { }; +template<> struct std::uses_allocator> : std::true_type { }; +template<> struct std::uses_allocator> : std::true_type { }; + +struct A { }; + +constexpr bool +test01() +{ + struct B { bool v; constexpr B(A&) : v(true) { } }; + + // template + // constexpr explicit(false) tuple(tuple&); + + tuple t1a; + tuple t1b = t1a; + VERIFY( std::get<0>(t1b).v ); + + tuple t2a0; + tuple t2b0 = t2a0; + VERIFY( std::get<0>(t2b0).v ); + + tuple t2a1; + tuple t2b1 = t2a1; + VERIFY( std::get<1>(t2b1).v ); + + tuple t3a0; + tuple t3b0 = t3a0; + VERIFY( std::get<0>(t3b0).v ); + + tuple t3a1; + tuple t3b1 = t3a1; + VERIFY( std::get<1>(t3b1).v ); + + tuple t3a2; + tuple t3b2 = t3a2; + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(false) tuple(pair&); + + pair p2a0; + tuple p2b0 = p2a0; + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + tuple p2b1 = p2a1; + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +namespace alloc +{ + struct B01 + { + bool v; + B01(A&); + constexpr B01(allocator_arg_t, allocator, A&) : v(true) { } + }; + + constexpr bool + test01() + { + using B = B01; + + // template + // constexpr explicit(false) + // tuple(allocator_arg_t, const Alloc& a, tuple&); + + tuple t1a; + tuple t1b = {allocator_arg, allocator{}, t1a}; + VERIFY( std::get<0>(t1b).v ); + + tuple t2a0; + tuple t2b0 = {allocator_arg, allocator{}, t2a0}; + VERIFY( std::get<0>(t2b0).v ); + + tuple t2a1; + tuple t2b1 = {allocator_arg, allocator{}, t2a1}; + VERIFY( std::get<1>(t2b1).v ); + + tuple t3a0; + tuple t3b0 = {allocator_arg, allocator{}, t3a0}; + VERIFY( std::get<0>(t3b0).v ); + + tuple t3a1; + tuple t3b1 = {allocator_arg, allocator{}, t3a1}; + VERIFY( std::get<1>(t3b1).v ); + + tuple t3a2; + tuple t3b2 = {allocator_arg, allocator{}, t3a2}; + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(false) + // tuple(allocator_arg_t, const Alloc& a, pair&); + + pair p2a0; + tuple p2b0 = {allocator_arg, allocator{}, p2a0}; + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + tuple p2b1 = {allocator_arg, allocator{}, p2a1}; + VERIFY( std::get<1>(p2b1).v ); + + return true; + } +} + +constexpr bool +test02() +{ + struct B { bool v; explicit constexpr B(A&) : v(true) { } }; + + // template + // constexpr explicit(true) tuple(tuple&); + + static_assert(!std::is_convertible_v&, tuple>); + + tuple t1a; + tuple t1b(t1a); + VERIFY( std::get<0>(t1b).v ); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + tuple t2a0; + tuple t2b0(t2a0); + VERIFY( std::get<0>(t2b0).v ); + + tuple t2a1; + tuple t2b1(t2a1); + VERIFY( std::get<1>(t2b1).v ); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + tuple t3a0; + tuple t3b0(t3a0); + VERIFY( std::get<0>(t3b0).v ); + + tuple t3a1; + tuple t3b1(t3a1); + VERIFY( std::get<1>(t3b1).v ); + + tuple t3a2; + tuple t3b2(t3a2); + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(true) tuple(pair&); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + pair p2a0; + tuple p2b0(p2a0); + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + tuple p2b1(p2a1); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +namespace alloc +{ + struct B02 + { + bool v; + explicit B02(A&); + explicit constexpr B02(allocator_arg_t, allocator, A&) : v(true) { } + }; + + constexpr bool + test02() + { + using B = B02; + + // template + // constexpr explicit(true) + // tuple(allocator_arg_t, const Alloc& a, tuple&); + + tuple t1a; + tuple t1b(allocator_arg, allocator{}, t1a); + VERIFY( std::get<0>(t1b).v ); + + tuple t2a0; + tuple t2b0(allocator_arg, allocator{}, t2a0); + VERIFY( std::get<0>(t2b0).v ); + + tuple t2a1; + tuple t2b1(allocator_arg, allocator{}, t2a1); + VERIFY( std::get<1>(t2b1).v ); + + tuple t3a0; + tuple t3b0(allocator_arg, allocator{}, t3a0); + VERIFY( std::get<0>(t3b0).v ); + + tuple t3a1; + tuple t3b1(allocator_arg, allocator{}, t3a1); + VERIFY( std::get<1>(t3b1).v ); + + tuple t3a2; + tuple t3b2(allocator_arg, allocator{}, t3a2); + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(true) + // tuple(allocator_arg_t, const Alloc& a, pair&); + + pair p2a0; + tuple p2b0(allocator_arg, allocator{}, p2a0); + VERIFY( std::get<0>(p2b0).v ); + + pair p2a1; + tuple p2b1(allocator_arg, allocator{}, p2a1); + VERIFY( std::get<1>(p2b1).v ); + + return true; + } +} // namespace alloc + +constexpr bool +test03() +{ + struct B { bool v; constexpr B(const A&&) : v(true) { } }; + + // template + // constexpr explicit(false) tuple(const tuple&&); + + const tuple t1a; + tuple t1b = std::move(t1a); + VERIFY( std::get<0>(t1b).v ); + + const tuple t2a0; + tuple t2b0 = std::move(t2a0); + VERIFY( std::get<0>(t2b0).v ); + + const tuple t2a1; + tuple t2b1 = std::move(t2a1); + VERIFY( std::get<1>(t2b1).v ); + + const tuple t3a0; + tuple t3b0 = std::move(t3a0); + VERIFY( std::get<0>(t3b0).v ); + + const tuple t3a1; + tuple t3b1 = std::move(t3a1); + VERIFY( std::get<1>(t3b1).v ); + + const tuple t3a2; + tuple t3b2 = std::move(t3a2); + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(false) tuple(const pair&&); + + const pair p2a0; + tuple p2b0 = std::move(p2a0); + VERIFY( std::get<0>(p2b0).v ); + + const pair p2a1; + tuple p2b1 = std::move(p2a1); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +namespace alloc +{ + struct B03 + { + bool v; + B03(const A&&); + constexpr B03(allocator_arg_t, allocator, const A&&) : v(true) { } + }; + + constexpr bool + test03() + { + using B = B03; + + // template + // constexpr explicit(false) + // tuple(allocator_arg_t, const Alloc& a, const tuple&&); + + const tuple t1a; + tuple t1b = {allocator_arg, allocator{}, std::move(t1a)}; + VERIFY( std::get<0>(t1b).v ); + + const tuple t2a0; + tuple t2b0 = {allocator_arg, allocator{}, std::move(t2a0)}; + VERIFY( std::get<0>(t2b0).v ); + + const tuple t2a1; + tuple t2b1 = {allocator_arg, allocator{}, std::move(t2a1)}; + VERIFY( std::get<1>(t2b1).v ); + + const tuple t3a0; + tuple t3b0 = {allocator_arg, allocator{}, std::move(t3a0)}; + VERIFY( std::get<0>(t3b0).v ); + + const tuple t3a1; + tuple t3b1 = {allocator_arg, allocator{}, std::move(t3a1)}; + VERIFY( std::get<1>(t3b1).v ); + + const tuple t3a2; + tuple t3b2 = {allocator_arg, allocator{}, std::move(t3a2)}; + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(false) + // tuple(allocator_arg_t, const Alloc& a, const pair&&); + + const pair p2a0; + tuple p2b0 = {allocator_arg, allocator{}, std::move(p2a0)}; + VERIFY( std::get<0>(p2b0).v ); + + const pair p2a1; + tuple p2b1 = {allocator_arg, allocator{}, std::move(p2a1)}; + VERIFY( std::get<1>(p2b1).v ); + + return true; + } +}; + +constexpr bool +test04() +{ + struct B { bool v; explicit constexpr B(const A&&) : v(true) { } }; + + // template + // constexpr explicit(true) tuple(const tuple&&); + + static_assert(!std::is_convertible_v&, tuple>); + + const tuple t1a; + tuple t1b(std::move(t1a)); + VERIFY( std::get<0>(t1b).v ); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + const tuple t2a0; + tuple t2b0(std::move(t2a0)); + VERIFY( std::get<0>(t2b0).v ); + + const tuple t2a1; + tuple t2b1(std::move(t2a1)); + VERIFY( std::get<1>(t2b1).v ); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + const tuple t3a0; + tuple t3b0(std::move(t3a0)); + VERIFY( std::get<0>(t3b0).v ); + + const tuple t3a1; + tuple t3b1(std::move(t3a1)); + VERIFY( std::get<1>(t3b1).v ); + + const tuple t3a2; + tuple t3b2(std::move(t3a2)); + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(true) tuple(const pair&&); + + static_assert(!std::is_convertible_v&, tuple>); + static_assert(!std::is_convertible_v&, tuple>); + + const pair p2a0; + tuple p2b0(std::move(p2a0)); + VERIFY( std::get<0>(p2b0).v ); + + const pair p2a1; + tuple p2b1(std::move(p2a1)); + VERIFY( std::get<1>(p2b1).v ); + + return true; +} + +namespace alloc +{ + struct B04 + { + bool v; + explicit B04(const A&&); + explicit constexpr B04(allocator_arg_t, allocator, const A&&) : v(true) { } + }; + + constexpr bool + test04() + { + using B = B04; + + // template + // constexpr explicit(true) + // tuple(allocator_arg_t, const Alloc& a, const tuple&&); + + const tuple t1a; + tuple t1b(allocator_arg, allocator{}, std::move(t1a)); + VERIFY( std::get<0>(t1b).v ); + + const tuple t2a0; + tuple t2b0(allocator_arg, allocator{}, std::move(t2a0)); + VERIFY( std::get<0>(t2b0).v ); + + const tuple t2a1; + tuple t2b1(allocator_arg, allocator{}, std::move(t2a1)); + VERIFY( std::get<1>(t2b1).v ); + + const tuple t3a0; + tuple t3b0(allocator_arg, allocator{}, std::move(t3a0)); + VERIFY( std::get<0>(t3b0).v ); + + const tuple t3a1; + tuple t3b1(allocator_arg, allocator{}, std::move(t3a1)); + VERIFY( std::get<1>(t3b1).v ); + + const tuple t3a2; + tuple t3b2(allocator_arg, allocator{}, std::move(t3a2)); + VERIFY( std::get<2>(t3b2).v ); + + // template + // constexpr explicit(true) + // tuple(allocator_arg_t, const Alloc& a, const pair&&); + + tuple p2b0(allocator_arg, allocator{}, std::move(t2a0)); + VERIFY( std::get<0>(p2b0).v ); + + tuple p2b1(allocator_arg, allocator{}, std::move(t2a1)); + VERIFY( std::get<1>(p2b1).v ); + + return true; + } +}; + +constexpr bool +test05() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(const A&) const { v = true; return *this; } + }; + + // template + // constexpr const tuple& operator=(const tuple&) const; + + const tuple t1a; + const tuple t1b; + t1b = t1a; + VERIFY( std::get<0>(t1b).v ); + + const tuple t2a; + const tuple t2b; + t2b = t2a; + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + const tuple t3a; + const tuple t3b; + t3b = t3a; + VERIFY( std::get<0>(t3b).v ); + VERIFY( std::get<1>(t3b).v ); + VERIFY( std::get<2>(t3b).v ); + + // template + // constexpr const tuple& operator=(const pair&) const; + + const pair p2a; + const tuple p2b; + p2b = p2a; + + return true; +} + +constexpr bool +test06() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(A&&) const { v = true; return *this; } + }; + + // template + // constexpr const tuple& operator=(tuple&&) const; + + tuple t1a; + const tuple t1b; + t1b = std::move(t1a); + VERIFY( std::get<0>(t1b).v ); + + tuple t2a; + const tuple t2b; + t2b = std::move(t2a); + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + tuple t3a; + const tuple t3b; + t3b = std::move(t3a); + VERIFY( std::get<0>(t3b).v ); + VERIFY( std::get<1>(t3b).v ); + VERIFY( std::get<2>(t3b).v ); + + // template + // constexpr const tuple& operator=(pair&&) const; + + pair p2a; + const tuple p2b; + p2b = std::move(p2a); + + return true; +} + +constexpr bool +test07() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(const B&) const { v = true; return *this; } + }; + + // constexpr const tuple& operator=(const tuple&) const; + + const tuple t1a; + const tuple t1b; + t1b = t1a; + VERIFY( std::get<0>(t1b).v ); + + const tuple t2a; + const tuple t2b; + t2b = t2a; + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + const tuple t3a; + const tuple t3b; + t3b = t3a; + VERIFY( std::get<0>(t3b).v ); + VERIFY( std::get<1>(t3b).v ); + VERIFY( std::get<2>(t3b).v ); + + return true; +} + +constexpr bool +test08() +{ + struct B + { + mutable bool v; + constexpr const B& operator=(B&&) const { v = true; return *this; } + }; + + // constexpr const tuple& operator=(tuple&&) const; + + tuple t1a; + const tuple t1b; + t1b = std::move(t1a); + VERIFY( std::get<0>(t1b).v ); + + tuple t2a; + const tuple t2b; + t2b = std::move(t2a); + VERIFY( std::get<0>(t2b).v ); + VERIFY( std::get<1>(t2b).v ); + + tuple t3a; + const tuple t3b; + t3b = std::move(t3a); + VERIFY( std::get<0>(t3b).v ); + VERIFY( std::get<1>(t3b).v ); + VERIFY( std::get<2>(t3b).v ); + + return true; +} + +struct S +{ + mutable int v = 0; + friend constexpr void swap(S&& x, S&& y) = delete; + friend constexpr void swap(const S& x, const S& y) { ++x.v; ++y.v; } +}; + +constexpr bool +test09() +{ + const tuple t1, u1; + std::swap(t1, u1); + VERIFY( std::get<0>(t1).v == 1 ); + VERIFY( std::get<0>(u1).v == 1 ); + + const tuple t2, u2; + std::swap(t2, u2); + VERIFY( std::get<0>(t2).v == 1 ); + VERIFY( std::get<0>(u2).v == 1 ); + VERIFY( std::get<1>(t2).v == 1 ); + VERIFY( std::get<1>(u2).v == 1 ); + + const tuple t3, u3; + std::swap(t3, u3); + VERIFY( std::get<0>(t3).v == 1 ); + VERIFY( std::get<0>(u3).v == 1 ); + VERIFY( std::get<1>(t3).v == 1 ); + VERIFY( std::get<1>(u3).v == 1 ); + VERIFY( std::get<2>(t3).v == 1 ); + VERIFY( std::get<2>(u3).v == 1 ); + + static_assert(!std::is_swappable_v&>); + + return true; +} + +int +main() +{ + static_assert(test01()); + static_assert(alloc::test01()); + static_assert(test02()); + static_assert(alloc::test02()); + static_assert(test03()); + static_assert(alloc::test03()); + static_assert(test04()); + static_assert(alloc::test04()); + // FIXME: G++ doesn't support reading mutable members during constexpr (PR c++/92505). + test05(); + test06(); + test07(); + test08(); + test09(); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/1.cc new file mode 100644 index 00000000000..9016c026b33 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/1.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } +// { dg-xfail-if "not supported" { debug_mode } } + +#include +#include + +constexpr bool +test01() +{ + // P2321R2 + // constexpr const reference& vector::operator=(bool x) const noexcept; + + std::vector v(1); + const auto e = v[0]; + e = true; + VERIFY( v[0] ); + + return true; +} + +int +main() +{ + static_assert(test01()); +}