[Patch] reduce template instantiation depth in <variant>

Barrett Adair barrettellisadair@gmail.com
Sat Nov 12 07:12:00 GMT 2016


Hi,

Currently, std::variant exceeds the default ftemplate-depth parameter
when instantiated with 297 types. This small patch increases this
ceiling to 446 types (from the bottom of the template stack).

This was accomplished by using fold expressions instead of the __and_ template.

Thanks,
Barrett
-------------- next part --------------
356c356
< 		  __and_<std::is_trivially_destructible<_Types>...>::value>
---
> 		  (std::is_trivially_destructible<_Types>::value &&...)>
379c379
<       noexcept(__and_<is_nothrow_move_constructible<_Types>...>::value)
---
>       noexcept((is_nothrow_move_constructible<_Types>::value && ...))
470,471c470,471
<       noexcept(__and_<is_nothrow_move_constructible<_Types>...,
< 		      is_nothrow_move_assignable<_Types>...>::value)
---
>       noexcept((is_nothrow_move_constructible<_Types>::value && ...)
> 		      && (is_nothrow_move_assignable<_Types>::value && ...))
962,968c962,968
< 	__and_<is_copy_constructible<_Types>...>::value,
< 	__and_<is_copy_constructible<_Types>...,
< 	       is_move_constructible<_Types>...,
< 	       is_copy_assignable<_Types>...>::value,
< 	__and_<is_move_constructible<_Types>...>::value,
< 	__and_<is_move_constructible<_Types>...,
< 	       is_move_assignable<_Types>...>::value,
---
>   (is_copy_constructible_v<_Types> && ...),
>   (is_copy_constructible_v<_Types> && ...)
>       && (is_move_constructible_v<_Types> && ...)
>       && (is_copy_assignable_v<_Types> && ...),
> 	(is_move_constructible_v<_Types> && ...),
> 	(is_move_constructible_v<_Types> && ...)
>       && (is_move_assignable_v<_Types> && ...),
1011,1012c1011
<       noexcept(__and_<
< 	is_nothrow_move_constructible<_Types>...>::value) = default;
---
>       noexcept((is_nothrow_move_constructible<_Types>::value &&...)) = default;
1070c1069
< 	       typename = enable_if_t<__and_<__is_uses_allocator_constructible<
---
> 	       typename = enable_if_t<(__is_uses_allocator_constructible<
1072c1071
< 		 add_lvalue_reference_t<add_const_t<_Types>>>...>::value>>
---
> 		 add_lvalue_reference_t<add_const_t<_Types>>>::value && ...)>>
1079c1078
< 	       typename = enable_if_t<__and_<
---
> 	       typename = enable_if_t<(
1081c1080
< 		   _Types, _Alloc, add_rvalue_reference_t<_Types>>...>::value>>
---
> 		   _Types, _Alloc, add_rvalue_reference_t<_Types>>::value && ...)>>
1144,1145c1143,1144
<       noexcept(__and_<is_nothrow_move_constructible<_Types>...,
< 		      is_nothrow_move_assignable<_Types>...>::value) = default;
---
>       noexcept((is_nothrow_move_constructible<_Types>::value && ...)
> 		      && (is_nothrow_move_assignable<_Types>::value && ...)) = default;
1229c1228
<       noexcept(__and_<__is_nothrow_swappable<_Types>...>::value
---
>       noexcept((__is_nothrow_swappable<_Types>::value && ...)


More information about the Libstdc++ mailing list