aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Shen <timshen@google.com>2017-05-28 21:27:30 +0000
committerTim Shen <timshen@gcc.gnu.org>2017-05-28 21:27:30 +0000
commita8127c0cca7dc6ee9c3eafa2058bac4406247a5d (patch)
treeda62554cee3e4bf3e6a5e1e4fa339db533258903
parent9698e1bb336c3d623231d7bb017681c2b82523dc (diff)
downloadgcc-a8127c0cca7dc6ee9c3eafa2058bac4406247a5d.zip
gcc-a8127c0cca7dc6ee9c3eafa2058bac4406247a5d.tar.gz
gcc-a8127c0cca7dc6ee9c3eafa2058bac4406247a5d.tar.bz2
re PR c++/80737 (variant<any> as class member resulting to compile errors)
PR libstdc++/80737 * include/std/variant(variant::variant): SFINAE on is_same first. * testsuite/20_util/variant/any.cc: test case. From-SVN: r248548
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/std/variant4
-rw-r--r--libstdc++-v3/testsuite/20_util/variant/any.cc31
3 files changed, 39 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index af0b472..c6aea96 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-20 Tim Shen <timshen@google.com>
+
+ PR libstdc++/80737
+ * include/std/variant(variant::variant): SFINAE on is_same first.
+ * testsuite/20_util/variant/any.cc: test case.
+
2017-05-24 Jonathan Wakely <jwakely@redhat.com>
* src/c++11/random.cc (random_device::_M_getentropy): Use __CHAR_BIT__
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 0e04a82..b9824a5 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -936,9 +936,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
noexcept((is_nothrow_move_constructible_v<_Types> && ...)) = default;
template<typename _Tp,
+ typename = enable_if_t<!is_same_v<decay_t<_Tp>, variant>>,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
- && is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>
- && !is_same_v<decay_t<_Tp>, variant>>>
+ && is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>>>
constexpr
variant(_Tp&& __t)
noexcept(is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp&&>)
diff --git a/libstdc++-v3/testsuite/20_util/variant/any.cc b/libstdc++-v3/testsuite/20_util/variant/any.cc
new file mode 100644
index 0000000..5811d0f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/variant/any.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2017 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 <any>
+#include <variant>
+
+struct A { std::variant<std::any> a; };
+
+void Bar(const A&);
+
+void Foo() {
+ A a;
+ Bar(a);
+}