Commit 258ee761 by Barrett Adair Committed by Jonathan Wakely

Use fold expressions to reduce std::variant instantiation depth

2017-01-06  Barrett Adair  <barrettellisadair@gmail.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	* include/std/variant (variant, swap): Replace __and_ usage with fold
	expressions.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>

From-SVN: r244163
parent 1ec62aa9
2017-01-06 Barrett Adair <barrettellisadair@gmail.com>
Jonathan Wakely <jwakely@redhat.com>
* include/std/variant (variant, swap): Replace __and_ usage with fold
expressions.
2017-01-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2017-01-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR go/78978 PR go/78978
......
...@@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
_Variant_base(_Variant_base&& __rhs) _Variant_base(_Variant_base&& __rhs)
noexcept(__and_<is_nothrow_move_constructible<_Types>...>::value) noexcept((is_nothrow_move_constructible_v<_Types> && ...))
{ {
if (__rhs._M_valid()) if (__rhs._M_valid())
{ {
...@@ -459,8 +459,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -459,8 +459,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Variant_base& _Variant_base&
operator=(_Variant_base&& __rhs) operator=(_Variant_base&& __rhs)
noexcept(__and_<is_nothrow_move_constructible<_Types>..., noexcept((is_nothrow_move_constructible_v<_Types> && ...)
is_nothrow_move_assignable<_Types>...>::value) && (is_nothrow_move_assignable_v<_Types> && ...))
{ {
if (this->_M_index == __rhs._M_index) if (this->_M_index == __rhs._M_index)
{ {
...@@ -865,8 +865,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -865,8 +865,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ __lhs.swap(__rhs); } { __lhs.swap(__rhs); }
template<typename... _Types> template<typename... _Types>
enable_if_t<!__and_<is_move_constructible<_Types>..., enable_if_t<!((is_move_constructible_v<_Types> && ...)
is_swappable<_Types>...>::value> && (is_swappable_v<_Types> && ...))>
swap(variant<_Types...>&, variant<_Types...>&) = delete; swap(variant<_Types...>&, variant<_Types...>&) = delete;
class bad_variant_access : public exception class bad_variant_access : public exception
...@@ -895,13 +895,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -895,13 +895,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_default_constructible_v< is_default_constructible_v<
variant_alternative_t<0, variant<_Types...>>>, variant<_Types...>>, variant_alternative_t<0, variant<_Types...>>>, variant<_Types...>>,
private _Enable_copy_move< private _Enable_copy_move<
__and_<is_copy_constructible<_Types>...>::value, (is_copy_constructible_v<_Types> && ...),
__and_<is_copy_constructible<_Types>..., (is_copy_constructible_v<_Types> && ...)
is_move_constructible<_Types>..., && (is_move_constructible_v<_Types> && ...)
is_copy_assignable<_Types>...>::value, && (is_copy_assignable_v<_Types> && ...),
__and_<is_move_constructible<_Types>...>::value, (is_move_constructible_v<_Types> && ...),
__and_<is_move_constructible<_Types>..., (is_move_constructible_v<_Types> && ...)
is_move_assignable<_Types>...>::value, && (is_move_assignable_v<_Types> && ...),
variant<_Types...>> variant<_Types...>>
{ {
private: private:
...@@ -948,8 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -948,8 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
noexcept(is_nothrow_default_constructible_v<__to_type<0>>) = default; noexcept(is_nothrow_default_constructible_v<__to_type<0>>) = default;
variant(const variant&) = default; variant(const variant&) = default;
variant(variant&&) variant(variant&&)
noexcept(__and_< noexcept((is_nothrow_move_constructible_v<_Types> && ...)) = default;
is_nothrow_move_constructible<_Types>...>::value) = default;
template<typename _Tp, template<typename _Tp,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>> typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
...@@ -1003,8 +1002,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1003,8 +1002,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
variant& operator=(const variant&) = default; variant& operator=(const variant&) = default;
variant& operator=(variant&&) variant& operator=(variant&&)
noexcept(__and_<is_nothrow_move_constructible<_Types>..., noexcept((is_nothrow_move_constructible_v<_Types> && ...)
is_nothrow_move_assignable<_Types>...>::value) = default; && (is_nothrow_move_assignable_v<_Types> && ...)) = default;
template<typename _Tp> template<typename _Tp>
enable_if_t<__exactly_once<__accepted_type<_Tp&&>> enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
...@@ -1091,7 +1090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1091,7 +1090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void void
swap(variant& __rhs) swap(variant& __rhs)
noexcept(__and_<__is_nothrow_swappable<_Types>...>::value noexcept((__is_nothrow_swappable<_Types>::value && ...)
&& is_nothrow_move_constructible_v<variant>) && is_nothrow_move_constructible_v<variant>)
{ {
if (this->index() == __rhs.index()) if (this->index() == __rhs.index())
......
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