diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index bdad76239b4..a6770e8f235 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -185,8 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Construct with a copy of @p __value as the contained object. template , typename _Mgr = _Manager<_VTp>, - typename = _Require<__not_<__is_in_place_type<_VTp>>, - is_copy_constructible<_VTp>>> + enable_if_t + && !__is_in_place_type_v<_VTp>, bool> = true> any(_Tp&& __value) : _M_manager(&_Mgr::_S_manage) { diff --git a/libstdc++-v3/testsuite/20_util/any/cons/104242.cc b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc new file mode 100644 index 00000000000..8d5868b7ff9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc @@ -0,0 +1,12 @@ +// { dg-do compile { target c++17 } } + +// PR libstdc++/104242 - Class with constructor from std::any is not copyable + +#include +#include + +struct A { + A(const A&) = default; + explicit A(std::any value); +}; +static_assert(std::is_copy_constructible_v);