This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] [add changelog] reduce template instantiation depth in <variant>
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Barrett Adair <barrettellisadair at gmail dot com>
- Cc: Tim Shen <timshen at google dot com>, Daniel Krügler <daniel dot kruegler at gmail dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 6 Jan 2017 15:26:36 +0000
- Subject: Re: [Patch] [add changelog] reduce template instantiation depth in <variant>
- Authentication-results: sourceware.org; auth=none
- References: <CAARDWz9UGmpwNiRu5NC_SriyzNVqJkWo27B9P7o__RgCo4Prmg@mail.gmail.com> <CAGNvRgByw+RAKGtcPRvUpcPpoRoA4dk=FCxS4F_uCTbD3YVGWg@mail.gmail.com> <CAG4ZjNnuRwUuMKoiGz-8v5YMzwakjKF9oBipSb_XfaCR5siwbQ@mail.gmail.com> <CAARDWz_9TygnnLzC9hoFR6dzheDSyyHgA++at_P0XftQcpx2gA@mail.gmail.com> <20161115121751.GE3145@redhat.com> <CAARDWz_JvPu2fXbXmDvm_umrTFvoQO2GANXBdBHeq5KFAhd3zQ@mail.gmail.com> <20161206123541.GI6326@redhat.com> <CAG4ZjNktEu7_5Fj2a2V8gcHNS4pZh8SBTFvod6-j93f=MqFvpg@mail.gmail.com> <CAARDWz-2nCAAO+9S5fdn7=FN1dyUKPLZ7E-A8LSNadt9K7fQtA@mail.gmail.com> <20161223012052.GZ895@redhat.com>
On 23/12/16 01:20 +0000, Jonathan Wakely wrote:
On 22/12/16 19:06 -0600, Barrett Adair wrote:
On Tue, Dec 6, 2016 at 1:24 PM, Tim Shen <timshen@google.com> wrote:
On Tue, Dec 6, 2016 at 4:35 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
I've rebased Barrett's patch against the latest variant code
(attached).
Tim, do we want to make this change? A variant of 400 alternatives
seems pretty extreme, but if we can support it without much trouble
then maybe it's good to do so.
Yes, go ahead.
Thanks!
--
Regards,
Tim Shen
Did this make it into a branch? I'm not seeing this in the trunk.
No, it hasn't been done yet.
Here's what I've committed to trunk.
Tested powerpc64le-linux.
commit 0d54934b56a44b1c26510e98a57cd2663153f51c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jan 6 14:47:48 2017 +0000
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.
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 1803315..3d025a7 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
_Variant_base(_Variant_base&& __rhs)
- noexcept(__and_<is_nothrow_move_constructible<_Types>...>::value)
+ noexcept((is_nothrow_move_constructible_v<_Types> && ...))
{
if (__rhs._M_valid())
{
@@ -459,8 +459,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Variant_base&
operator=(_Variant_base&& __rhs)
- noexcept(__and_<is_nothrow_move_constructible<_Types>...,
- is_nothrow_move_assignable<_Types>...>::value)
+ noexcept((is_nothrow_move_constructible_v<_Types> && ...)
+ && (is_nothrow_move_assignable_v<_Types> && ...))
{
if (this->_M_index == __rhs._M_index)
{
@@ -865,8 +865,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ __lhs.swap(__rhs); }
template<typename... _Types>
- enable_if_t<!__and_<is_move_constructible<_Types>...,
- is_swappable<_Types>...>::value>
+ enable_if_t<!((is_move_constructible_v<_Types> && ...)
+ && (is_swappable_v<_Types> && ...))>
swap(variant<_Types...>&, variant<_Types...>&) = delete;
class bad_variant_access : public exception
@@ -895,13 +895,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_default_constructible_v<
variant_alternative_t<0, variant<_Types...>>>, variant<_Types...>>,
private _Enable_copy_move<
- __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> && ...),
variant<_Types...>>
{
private:
@@ -948,8 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
noexcept(is_nothrow_default_constructible_v<__to_type<0>>) = default;
variant(const variant&) = default;
variant(variant&&)
- noexcept(__and_<
- is_nothrow_move_constructible<_Types>...>::value) = default;
+ noexcept((is_nothrow_move_constructible_v<_Types> && ...)) = default;
template<typename _Tp,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
@@ -1003,8 +1002,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
variant& operator=(const variant&) = default;
variant& operator=(variant&&)
- noexcept(__and_<is_nothrow_move_constructible<_Types>...,
- is_nothrow_move_assignable<_Types>...>::value) = default;
+ noexcept((is_nothrow_move_constructible_v<_Types> && ...)
+ && (is_nothrow_move_assignable_v<_Types> && ...)) = default;
template<typename _Tp>
enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
@@ -1091,7 +1090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
swap(variant& __rhs)
- noexcept(__and_<__is_nothrow_swappable<_Types>...>::value
+ noexcept((__is_nothrow_swappable<_Types>::value && ...)
&& is_nothrow_move_constructible_v<variant>)
{
if (this->index() == __rhs.index())