Commit 6d1402f0 by Edward Smith-Rowland Committed by Edward Smith-Rowland

Implement the <tuple> part of C++20 p1032 Misc constexpr bits.

2019-11-15  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement the <tuple> part of C++20 p1032 Misc constexpr bits.
	* include/std/tuple (_Head_base, _Tuple_impl(allocator_arg_t,...)
	(_M_assign, tuple(allocator_arg_t,...), _Inherited, operator=, _M_swap)
	(swap, pair(piecewise_construct_t,): Constexpr.
	* (__uses_alloc0::_Sink::operator=, __uses_alloc_t): Constexpr.
	* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: New test.
	* testsuite/20_util/tuple/constexpr_swap.cc : New test.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Extra error for C++20.
	* testsuite/20_util/uses_allocator/cons_neg.cc: : Extra error for C++20.

From-SVN: r278331
parent 97e4a5ee
2019-11-15 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement the <tuple> part of C++20 p1032 Misc constexpr bits.
* include/std/tuple (_Head_base, _Tuple_impl(allocator_arg_t,...)
(_M_assign, tuple(allocator_arg_t,...), _Inherited, operator=, _M_swap)
(swap, pair(piecewise_construct_t,): Constexpr.
* (__uses_alloc0::_Sink::operator=, __uses_alloc_t): Constexpr.
* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: New test.
* testsuite/20_util/tuple/constexpr_swap.cc : New test.
* testsuite/20_util/uses_allocator/69293_neg.cc: Extra error for C++20.
* testsuite/20_util/uses_allocator/cons_neg.cc: : Extra error for C++20.
2019-11-15 Jonathan Wakely <jwakely@redhat.com> 2019-11-15 Jonathan Wakely <jwakely@redhat.com>
* include/std/stop_token: Reduce header dependencies by including * include/std/stop_token: Reduce header dependencies by including
......
...@@ -132,6 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -132,6 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr _Head_base(_UHead&& __h) constexpr _Head_base(_UHead&& __h)
: _M_head_impl(std::forward<_UHead>(__h)) { } : _M_head_impl(std::forward<_UHead>(__h)) { }
_GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc0) _Head_base(allocator_arg_t, __uses_alloc0)
: _M_head_impl() { } : _M_head_impl() { }
...@@ -144,6 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -144,6 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_head_impl(*__a._M_a) { } : _M_head_impl(*__a._M_a) { }
template<typename _UHead> template<typename _UHead>
_GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc0, _UHead&& __uhead) _Head_base(__uses_alloc0, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead)) { } : _M_head_impl(std::forward<_UHead>(__uhead)) { }
...@@ -243,6 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -243,6 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a), : _Inherited(__tag, __a),
_Base(__tag, __use_alloc<_Head>(__a)) { } _Base(__tag, __use_alloc<_Head>(__a)) { }
...@@ -256,6 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -256,6 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _UHead, typename... _UTail, template<typename _Alloc, typename _UHead, typename... _UTail,
typename = typename enable_if<sizeof...(_Tail) typename = typename enable_if<sizeof...(_Tail)
== sizeof...(_UTail)>::type> == sizeof...(_UTail)>::type>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_UHead&& __head, _UTail&&... __tail) _UHead&& __head, _UTail&&... __tail)
: _Inherited(__tag, __a, std::forward<_UTail>(__tail)...), : _Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
...@@ -263,12 +267,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -263,12 +267,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::forward<_UHead>(__head)) { } std::forward<_UHead>(__head)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl& __in) const _Tuple_impl& __in)
: _Inherited(__tag, __a, _M_tail(__in)), : _Inherited(__tag, __a, _M_tail(__in)),
_Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { } _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl&& __in) _Tuple_impl&& __in)
: _Inherited(__tag, __a, std::move(_M_tail(__in))), : _Inherited(__tag, __a, std::move(_M_tail(__in))),
...@@ -276,6 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -276,6 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::forward<_Head>(_M_head(__in))) { } std::forward<_Head>(_M_head(__in))) { }
template<typename _Alloc, typename... _UElements> template<typename _Alloc, typename... _UElements>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl<_Idx, _UElements...>& __in) const _Tuple_impl<_Idx, _UElements...>& __in)
: _Inherited(__tag, __a, : _Inherited(__tag, __a,
...@@ -284,6 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -284,6 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { } _Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
template<typename _Alloc, typename _UHead, typename... _UTails> template<typename _Alloc, typename _UHead, typename... _UTails>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
: _Inherited(__tag, __a, std::move : _Inherited(__tag, __a, std::move
...@@ -293,6 +301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -293,6 +301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
template<typename... _UElements> template<typename... _UElements>
_GLIBCXX20_CONSTEXPR
void void
_M_assign(const _Tuple_impl<_Idx, _UElements...>& __in) _M_assign(const _Tuple_impl<_Idx, _UElements...>& __in)
{ {
...@@ -302,6 +311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -302,6 +311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _UHead, typename... _UTails> template<typename _UHead, typename... _UTails>
_GLIBCXX20_CONSTEXPR
void void
_M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
{ {
...@@ -312,6 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -312,6 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
protected: protected:
_GLIBCXX20_CONSTEXPR
void void
_M_swap(_Tuple_impl& __in) _M_swap(_Tuple_impl& __in)
{ {
...@@ -369,6 +380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -369,6 +380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ } { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
: _Base(__tag, __use_alloc<_Head>(__a)) { } : _Base(__tag, __use_alloc<_Head>(__a)) { }
...@@ -378,29 +390,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -378,29 +390,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { } : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
template<typename _Alloc, typename _UHead> template<typename _Alloc, typename _UHead>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_UHead&& __head) _UHead&& __head)
: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
std::forward<_UHead>(__head)) { } std::forward<_UHead>(__head)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl& __in) const _Tuple_impl& __in)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { } : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl&& __in) _Tuple_impl&& __in)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
std::forward<_Head>(_M_head(__in))) { } std::forward<_Head>(_M_head(__in))) { }
template<typename _Alloc, typename _UHead> template<typename _Alloc, typename _UHead>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl<_Idx, _UHead>& __in) const _Tuple_impl<_Idx, _UHead>& __in)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { } _Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
template<typename _Alloc, typename _UHead> template<typename _Alloc, typename _UHead>
_GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl<_Idx, _UHead>&& __in) _Tuple_impl<_Idx, _UHead>&& __in)
: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
...@@ -408,6 +425,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -408,6 +425,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ } { }
template<typename _UHead> template<typename _UHead>
_GLIBCXX20_CONSTEXPR
void void
_M_assign(const _Tuple_impl<_Idx, _UHead>& __in) _M_assign(const _Tuple_impl<_Idx, _UHead>& __in)
{ {
...@@ -415,6 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -415,6 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _UHead> template<typename _UHead>
_GLIBCXX20_CONSTEXPR
void void
_M_assign(_Tuple_impl<_Idx, _UHead>&& __in) _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
{ {
...@@ -423,6 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -423,6 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
protected: protected:
_GLIBCXX20_CONSTEXPR
void void
_M_swap(_Tuple_impl& __in) _M_swap(_Tuple_impl& __in)
{ {
...@@ -680,17 +700,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -680,17 +700,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, template<typename _Alloc,
_ImplicitDefaultCtor<is_object<_Alloc>::value> = true> _ImplicitDefaultCtor<is_object<_Alloc>::value> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a) tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { } : _Inherited(__tag, __a) { }
template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1), template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1),
_ImplicitCtor<_NotEmpty, const _Elements&...> = true> _ImplicitCtor<_NotEmpty, const _Elements&...> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const _Elements&... __elements) const _Elements&... __elements)
: _Inherited(__tag, __a, __elements...) { } : _Inherited(__tag, __a, __elements...) { }
template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1), template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1),
_ExplicitCtor<_NotEmpty, const _Elements&...> = false> _ExplicitCtor<_NotEmpty, const _Elements&...> = false>
_GLIBCXX20_CONSTEXPR
explicit explicit
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const _Elements&... __elements) const _Elements&... __elements)
...@@ -699,6 +722,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -699,6 +722,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename... _UElements, template<typename _Alloc, typename... _UElements,
bool _Valid = __valid_args<_UElements...>(), bool _Valid = __valid_args<_UElements...>(),
_ImplicitCtor<_Valid, _UElements...> = true> _ImplicitCtor<_Valid, _UElements...> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
_UElements&&... __elements) _UElements&&... __elements)
: _Inherited(__tag, __a, std::forward<_UElements>(__elements)...) : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
...@@ -707,6 +731,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -707,6 +731,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename... _UElements, template<typename _Alloc, typename... _UElements,
bool _Valid = __valid_args<_UElements...>(), bool _Valid = __valid_args<_UElements...>(),
_ExplicitCtor<_Valid, _UElements...> = false> _ExplicitCtor<_Valid, _UElements...> = false>
_GLIBCXX20_CONSTEXPR
explicit explicit
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
_UElements&&... __elements) _UElements&&... __elements)
...@@ -714,10 +739,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -714,10 +739,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ } { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
: _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { } : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
: _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
...@@ -725,6 +752,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -725,6 +752,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements))
&& !__use_other_ctor<const tuple<_UElements...>&>(), && !__use_other_ctor<const tuple<_UElements...>&>(),
_ImplicitCtor<_Valid, const _UElements&...> = true> _ImplicitCtor<_Valid, const _UElements&...> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_UElements...>& __in) const tuple<_UElements...>& __in)
: _Inherited(__tag, __a, : _Inherited(__tag, __a,
...@@ -735,6 +763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -735,6 +763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements))
&& !__use_other_ctor<const tuple<_UElements...>&>(), && !__use_other_ctor<const tuple<_UElements...>&>(),
_ExplicitCtor<_Valid, const _UElements&...> = false> _ExplicitCtor<_Valid, const _UElements&...> = false>
_GLIBCXX20_CONSTEXPR
explicit explicit
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_UElements...>& __in) const tuple<_UElements...>& __in)
...@@ -746,6 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -746,6 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements))
&& !__use_other_ctor<tuple<_UElements...>&&>(), && !__use_other_ctor<tuple<_UElements...>&&>(),
_ImplicitCtor<_Valid, _UElements...> = true> _ImplicitCtor<_Valid, _UElements...> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
tuple<_UElements...>&& __in) tuple<_UElements...>&& __in)
: _Inherited(__tag, __a, : _Inherited(__tag, __a,
...@@ -756,6 +786,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -756,6 +786,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements))
&& !__use_other_ctor<tuple<_UElements...>&&>(), && !__use_other_ctor<tuple<_UElements...>&&>(),
_ExplicitCtor<_Valid, _UElements...> = false> _ExplicitCtor<_Valid, _UElements...> = false>
_GLIBCXX20_CONSTEXPR
explicit explicit
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
tuple<_UElements...>&& __in) tuple<_UElements...>&& __in)
...@@ -765,6 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -765,6 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// tuple assignment // tuple assignment
_GLIBCXX20_CONSTEXPR
tuple& tuple&
operator=(typename conditional<__assignable<const _Elements&...>(), operator=(typename conditional<__assignable<const _Elements&...>(),
const tuple&, const tuple&,
...@@ -775,6 +807,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -775,6 +807,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
_GLIBCXX20_CONSTEXPR
tuple& tuple&
operator=(typename conditional<__assignable<_Elements...>(), operator=(typename conditional<__assignable<_Elements...>(),
tuple&&, tuple&&,
...@@ -786,6 +819,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -786,6 +819,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename... _UElements> template<typename... _UElements>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<const _UElements&...>(), tuple&> __enable_if_t<__assignable<const _UElements&...>(), tuple&>
operator=(const tuple<_UElements...>& __in) operator=(const tuple<_UElements...>& __in)
noexcept(__nothrow_assignable<const _UElements&...>()) noexcept(__nothrow_assignable<const _UElements&...>())
...@@ -795,6 +829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -795,6 +829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename... _UElements> template<typename... _UElements>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<_UElements...>(), tuple&> __enable_if_t<__assignable<_UElements...>(), tuple&>
operator=(tuple<_UElements...>&& __in) operator=(tuple<_UElements...>&& __in)
noexcept(__nothrow_assignable<_UElements...>()) noexcept(__nothrow_assignable<_UElements...>())
...@@ -804,6 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -804,6 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
// tuple swap // tuple swap
_GLIBCXX20_CONSTEXPR
void void
swap(tuple& __in) swap(tuple& __in)
noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value) noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
...@@ -834,8 +870,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -834,8 +870,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple() = default; tuple() = default;
// No-op allocator constructors. // No-op allocator constructors.
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t, const _Alloc&) noexcept { } tuple(allocator_arg_t, const _Alloc&) noexcept { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept { } tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept { }
}; };
...@@ -1015,11 +1053,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1015,11 +1053,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, template<typename _Alloc,
_ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = true> _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a) tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { } : _Inherited(__tag, __a) { }
template<typename _Alloc, bool _Dummy = true, template<typename _Alloc, bool _Dummy = true,
_ImplicitCtor<_Dummy, const _T1&, const _T2&> = true> _ImplicitCtor<_Dummy, const _T1&, const _T2&> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const _T1& __a1, const _T2& __a2) const _T1& __a1, const _T2& __a2)
: _Inherited(__tag, __a, __a1, __a2) { } : _Inherited(__tag, __a, __a1, __a2) { }
...@@ -1027,12 +1067,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1027,12 +1067,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, bool _Dummy = true, template<typename _Alloc, bool _Dummy = true,
_ExplicitCtor<_Dummy, const _T1&, const _T2&> = false> _ExplicitCtor<_Dummy, const _T1&, const _T2&> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const _T1& __a1, const _T2& __a2) const _T1& __a1, const _T2& __a2)
: _Inherited(__tag, __a, __a1, __a2) { } : _Inherited(__tag, __a, __a1, __a2) { }
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ImplicitCtor<true, _U1, _U2> = true> _ImplicitCtor<true, _U1, _U2> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2) tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2)
: _Inherited(__tag, __a, std::forward<_U1>(__a1), : _Inherited(__tag, __a, std::forward<_U1>(__a1),
std::forward<_U2>(__a2)) { } std::forward<_U2>(__a2)) { }
...@@ -1040,21 +1082,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1040,21 +1082,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ExplicitCtor<true, _U1, _U2> = false> _ExplicitCtor<true, _U1, _U2> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
_U1&& __a1, _U2&& __a2) _U1&& __a1, _U2&& __a2)
: _Inherited(__tag, __a, std::forward<_U1>(__a1), : _Inherited(__tag, __a, std::forward<_U1>(__a1),
std::forward<_U2>(__a2)) { } std::forward<_U2>(__a2)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
: _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { } : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
template<typename _Alloc> template<typename _Alloc>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
: _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ImplicitCtor<true, const _U1&, const _U2&> = true> _ImplicitCtor<true, const _U1&, const _U2&> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_U1, _U2>& __in) const tuple<_U1, _U2>& __in)
: _Inherited(__tag, __a, : _Inherited(__tag, __a,
...@@ -1064,6 +1110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1064,6 +1110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ExplicitCtor<true, const _U1&, const _U2&> = false> _ExplicitCtor<true, const _U1&, const _U2&> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_U1, _U2>& __in) const tuple<_U1, _U2>& __in)
: _Inherited(__tag, __a, : _Inherited(__tag, __a,
...@@ -1072,6 +1119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1072,6 +1119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ImplicitCtor<true, _U1, _U2> = true> _ImplicitCtor<true, _U1, _U2> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
: _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in))
{ } { }
...@@ -1079,12 +1127,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1079,12 +1127,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ExplicitCtor<true, _U1, _U2> = false> _ExplicitCtor<true, _U1, _U2> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
: _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in))
{ } { }
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ImplicitCtor<true, const _U1&, const _U2&> = true> _ImplicitCtor<true, const _U1&, const _U2&> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const pair<_U1, _U2>& __in) const pair<_U1, _U2>& __in)
: _Inherited(__tag, __a, __in.first, __in.second) { } : _Inherited(__tag, __a, __in.first, __in.second) { }
...@@ -1092,12 +1142,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1092,12 +1142,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ExplicitCtor<true, const _U1&, const _U2&> = false> _ExplicitCtor<true, const _U1&, const _U2&> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple(allocator_arg_t __tag, const _Alloc& __a,
const pair<_U1, _U2>& __in) const pair<_U1, _U2>& __in)
: _Inherited(__tag, __a, __in.first, __in.second) { } : _Inherited(__tag, __a, __in.first, __in.second) { }
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ImplicitCtor<true, _U1, _U2> = true> _ImplicitCtor<true, _U1, _U2> = true>
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
: _Inherited(__tag, __a, std::forward<_U1>(__in.first), : _Inherited(__tag, __a, std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { } std::forward<_U2>(__in.second)) { }
...@@ -1105,10 +1157,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1105,10 +1157,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc, typename _U1, typename _U2, template<typename _Alloc, typename _U1, typename _U2,
_ExplicitCtor<true, _U1, _U2> = false> _ExplicitCtor<true, _U1, _U2> = false>
explicit explicit
_GLIBCXX20_CONSTEXPR
tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
: _Inherited(__tag, __a, std::forward<_U1>(__in.first), : _Inherited(__tag, __a, std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { } std::forward<_U2>(__in.second)) { }
// Tuple assignment.
_GLIBCXX20_CONSTEXPR
tuple& tuple&
operator=(typename conditional<__assignable<const _T1&, const _T2&>(), operator=(typename conditional<__assignable<const _T1&, const _T2&>(),
const tuple&, const tuple&,
...@@ -1119,6 +1175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1119,6 +1175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
_GLIBCXX20_CONSTEXPR
tuple& tuple&
operator=(typename conditional<__assignable<_T1, _T2>(), operator=(typename conditional<__assignable<_T1, _T2>(),
tuple&&, tuple&&,
...@@ -1130,6 +1187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1130,6 +1187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _U1, typename _U2> template<typename _U1, typename _U2>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&> __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
operator=(const tuple<_U1, _U2>& __in) operator=(const tuple<_U1, _U2>& __in)
noexcept(__nothrow_assignable<const _U1&, const _U2&>()) noexcept(__nothrow_assignable<const _U1&, const _U2&>())
...@@ -1139,6 +1197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1139,6 +1197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _U1, typename _U2> template<typename _U1, typename _U2>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<_U1, _U2>(), tuple&> __enable_if_t<__assignable<_U1, _U2>(), tuple&>
operator=(tuple<_U1, _U2>&& __in) operator=(tuple<_U1, _U2>&& __in)
noexcept(__nothrow_assignable<_U1, _U2>()) noexcept(__nothrow_assignable<_U1, _U2>())
...@@ -1148,6 +1207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1148,6 +1207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _U1, typename _U2> template<typename _U1, typename _U2>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&> __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
operator=(const pair<_U1, _U2>& __in) operator=(const pair<_U1, _U2>& __in)
noexcept(__nothrow_assignable<const _U1&, const _U2&>()) noexcept(__nothrow_assignable<const _U1&, const _U2&>())
...@@ -1158,6 +1218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1158,6 +1218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
template<typename _U1, typename _U2> template<typename _U1, typename _U2>
_GLIBCXX20_CONSTEXPR
__enable_if_t<__assignable<_U1, _U2>(), tuple&> __enable_if_t<__assignable<_U1, _U2>(), tuple&>
operator=(pair<_U1, _U2>&& __in) operator=(pair<_U1, _U2>&& __in)
noexcept(__nothrow_assignable<_U1, _U2>()) noexcept(__nothrow_assignable<_U1, _U2>())
...@@ -1167,6 +1228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1167,6 +1228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
_GLIBCXX20_CONSTEXPR
void void
swap(tuple& __in) swap(tuple& __in)
noexcept(__and_<__is_nothrow_swappable<_T1>, noexcept(__and_<__is_nothrow_swappable<_T1>,
...@@ -1521,6 +1583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1521,6 +1583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// swap /// swap
template<typename... _Elements> template<typename... _Elements>
_GLIBCXX20_CONSTEXPR
inline inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1 // Constrained free swap overload, see p0185r1
...@@ -1535,6 +1598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1535,6 +1598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
template<typename... _Elements> template<typename... _Elements>
_GLIBCXX20_CONSTEXPR
typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
#endif #endif
...@@ -1570,7 +1634,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1570,7 +1634,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<class _T1, class _T2> template<class _T1, class _T2>
template<typename... _Args1, typename... _Args2> template<typename... _Args1, typename... _Args2>
_GLIBCXX20_CONSTEXPR inline _GLIBCXX20_CONSTEXPR
inline
pair<_T1, _T2>:: pair<_T1, _T2>::
pair(piecewise_construct_t, pair(piecewise_construct_t,
tuple<_Args1...> __first, tuple<_Args2...> __second) tuple<_Args1...> __first, tuple<_Args2...> __second)
......
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
//
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <memory>
#include <tuple>
const std::allocator<int> alloc{};
constexpr bool
test_tuple()
{
auto ok = true;
std::tuple<int, double, double> ta(std::allocator_arg, alloc);
std::tuple<int, double, double> tb(std::allocator_arg, alloc, 0, 3.456, 6.789);
std::tuple<int, double, double> tc(std::allocator_arg, alloc, 0, 3.456f, 6.789f);
std::tuple<int, double, double> td(std::allocator_arg, alloc, tb);
std::tuple<int, double, double> te(std::allocator_arg, alloc, std::move(tb));
std::tuple<int, float, float> tf(std::allocator_arg, alloc, 0, 3.456f, 6.789f);
std::tuple<int, double, double> tg(std::allocator_arg, alloc, tf);
std::tuple<int, double, double> th(std::allocator_arg, alloc, std::move(tf));
std::pair<int, float> pf(12, 3.142f);
std::tuple<int, double> ti(std::allocator_arg, alloc, pf);
std::tuple<int, double> tj(std::allocator_arg, alloc, std::move(pf));
return ok;
}
static_assert(test_tuple());
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
//
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <tuple>
constexpr bool
test_tuple()
{
auto ok = true;
std::tuple<int, double, double> t1(1, 3.1415, 2.7182);
std::tuple<int, double, double> t2(1, 4.1234, 3.3333);
t1.swap(t2);
std::swap(t1, t2);
return ok;
}
static_assert(test_tuple());
...@@ -45,4 +45,5 @@ test01() ...@@ -45,4 +45,5 @@ test01()
alloc_type a; alloc_type a;
std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed
// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 } // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
// { dg-error "no matching function for call" "" { target c++2a } 0 }
} }
...@@ -44,3 +44,4 @@ void test01() ...@@ -44,3 +44,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1); tuple<Type> t(allocator_arg, a, 1);
} }
// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 } // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
// { dg-error "no matching function for call" "" { target c++2a } 0 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment