Răsfoiți Sursa

any: less sfinae, more concepts

skypjack 1 lună în urmă
părinte
comite
8e5b05301b
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      src/entt/core/any.hpp

+ 5 - 2
src/entt/core/any.hpp

@@ -1,6 +1,7 @@
 #ifndef ENTT_CORE_ANY_HPP
 #define ENTT_CORE_ANY_HPP
 
+#include <concepts>
 #include <cstddef>
 #include <memory>
 #include <type_traits>
@@ -222,7 +223,8 @@ public:
      * @tparam Type Type of object to use to initialize the wrapper.
      * @param value An instance of an object to use to initialize the wrapper.
      */
-    template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
+    template<typename Type>
+    requires (!std::same_as<std::remove_cvref_t<Type>, basic_any>)
     basic_any(Type &&value)
         : basic_any{std::in_place_type<std::decay_t<Type>>, std::forward<Type>(value)} {}
 
@@ -306,7 +308,8 @@ public:
      * @param value An instance of an object to use to initialize the wrapper.
      * @return This any object.
      */
-    template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
+    template<typename Type>
+    requires (!std::same_as<std::remove_cvref_t<Type>, basic_any>)
     basic_any &operator=(Type &&value) {
         emplace<std::decay_t<Type>>(std::forward<Type>(value));
         return *this;