]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Simplify constraints for std::any construction
authorJonathan Wakely <jwakely@redhat.com>
Mon, 4 Oct 2021 22:14:30 +0000 (23:14 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 5 Oct 2021 14:56:56 +0000 (15:56 +0100)
libstdc++-v3/ChangeLog:

* include/bits/utility.h (__is_in_place_type_v): Define
variable template to detect in_place_type_t specializations.
(__is_in_place_type): Replace class template with alias
template using __is_in_place_type_v.
* include/std/any (any(T&&)): Check __is_in_place_type first and
avoid instantiating is_copy_constructible unnecessarily.

libstdc++-v3/include/bits/utility.h
libstdc++-v3/include/std/any

index 96d350874d9287df2c2b1d50a1fd1ff06dffb604..fce52a4530df77624f6a606a4e27b9791d902107 100644 (file)
@@ -184,17 +184,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline constexpr in_place_index_t<_Idx> in_place_index{};
 
   template<typename>
-    struct __is_in_place_type_impl : false_type
-    { };
+    inline constexpr bool __is_in_place_type_v = false;
 
   template<typename _Tp>
-    struct __is_in_place_type_impl<in_place_type_t<_Tp>> : true_type
-    { };
+    inline constexpr bool __is_in_place_type_v<in_place_type_t<_Tp>> = true;
 
   template<typename _Tp>
-    struct __is_in_place_type
-      : public __is_in_place_type_impl<_Tp>
-    { };
+    using __is_in_place_type = bool_constant<__is_in_place_type_v<_Tp>>;
+
 #endif // C++17
 #endif // C++14
 
index 625cac619f09d26d16bbbfcaaae647360777e306..e3d9d774de42f737b3019a99e3858c7d635d8dcf 100644 (file)
@@ -183,8 +183,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// Construct with a copy of @p __value as the contained object.
     template <typename _Tp, typename _VTp = _Decay_if_not_any<_Tp>,
              typename _Mgr = _Manager<_VTp>,
-             enable_if_t<is_copy_constructible<_VTp>::value
-                         && !__is_in_place_type<_VTp>::value, bool> = true>
+             typename = _Require<__not_<__is_in_place_type<_VTp>>,
+                                 is_copy_constructible<_VTp>>>
       any(_Tp&& __value)
       : _M_manager(&_Mgr::_S_manage)
       {