This patch corrects the requirement  of 4,5 and 6th constructor
As per https://en.cppreference.com/w/cpp/utility/any/any.

ChangeLog:
2020-04-17  Kamlesh Kumar  <kamleshbha...@gmail.com>

        PR libstdc++/92156
        * include/std/any (ans::any(_ValueType &&):: Remove
is_constructible.
        (any::any(in_place_type_t<_ValueType>, _Args&&...)): Use decay_t.
        (any::any(in_place_type_t<_ValueType>,initializer_list<_Up>,
_Args&&...)):
        Use decay_t.
         * testsuite/20_util/any/misc/92156.cc: New Test.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..fb212eb2231 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// Construct with a copy of @p __value as the contained object.
     template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
       typename _Mgr = _Manager<_Tp>,
-              __any_constructible_t<_Tp, _ValueType&&> = true,
-      enable_if_t<!__is_in_place_type<_Tp>::value, bool> = true>
+      enable_if_t<is_copy_constructible<_Tp>::value &&
+                          !__is_in_place_type<_Tp>::value, bool> = true>
       any(_ValueType&& __value)
       : _M_manager(&_Mgr::_S_manage)
       {
         _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
       }

-    /// Construct with a copy of @p __value as the contained object.
-    template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
-      typename _Mgr = _Manager<_Tp>,
-              enable_if_t<__and_v<is_copy_constructible<_Tp>,
-  __not_<is_constructible<_Tp, _ValueType&&>>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-      any(_ValueType&& __value)
-      : _M_manager(&_Mgr::_S_manage)
-      {
-        _Mgr::_S_create(_M_storage, __value);
-      }
-
     /// Construct with an object created from @p __args as the contained
object.
     template <typename _ValueType, typename... _Args,
-      typename _Tp = _Decay<_ValueType>,
+      typename _Tp = decay_t<_ValueType>,
       typename _Mgr = _Manager<_Tp>,
               __any_constructible_t<_Tp, _Args&&...> = false>
       explicit
@@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// Construct with an object created from @p __il and @p __args as
     /// the contained object.
     template <typename _ValueType, typename _Up, typename... _Args,
-      typename _Tp = _Decay<_ValueType>,
+      typename _Tp = decay_t<_ValueType>,
       typename _Mgr = _Manager<_Tp>,
               __any_constructible_t<_Tp, initializer_list<_Up>,
     _Args&&...> = false>
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 00000000000..c4f1ed55aee
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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 <utility>
+#include <tuple>
+
+int main() {
+    auto a = std::any(std::in_place_type<std::any>, 5);
+    auto b = std::any(std::in_place_type<std::any>, {1});
+    std::any p = std::pair<std::any, std::any>(1, 1);
+    (void)p;
+    std::any t = std::tuple<std::any>(1);
+    (void)t;
+    return 0;
+}
+

Regtested on X86_64-linux.

Thanks,

Reply via email to