Pārlūkot izejas kodu

container: less sfinae, more concepts

skypjack 1 mēnesi atpakaļ
vecāks
revīzija
efe67a700d

+ 4 - 2
src/entt/container/dense_map.hpp

@@ -81,7 +81,8 @@ public:
     constexpr dense_map_iterator(const It iter) noexcept
         : it{iter} {}
 
-    template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
+    template<typename Other>
+    requires !std::same_as<It, Other> && std::constructible_from<It, Other>
     constexpr dense_map_iterator(const dense_map_iterator<Other> &other) noexcept
         : it{other.it} {}
 
@@ -175,7 +176,8 @@ public:
         : it{iter},
           offset{pos} {}
 
-    template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
+    template<typename Other>
+    requires !std::same_as<It, Other> && std::constructible_from<It, Other>
     constexpr dense_map_local_iterator(const dense_map_local_iterator<Other> &other) noexcept
         : it{other.it},
           offset{other.offset} {}

+ 4 - 2
src/entt/container/dense_set.hpp

@@ -48,7 +48,8 @@ public:
     constexpr dense_set_iterator(const It iter) noexcept
         : it{iter} {}
 
-    template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
+    template<typename Other>
+    requires !std::same_as<It, Other> && std::constructible_from<It, Other>
     constexpr dense_set_iterator(const dense_set_iterator<Other> &other) noexcept
         : it{other.it} {}
 
@@ -139,7 +140,8 @@ public:
         : it{iter},
           offset{pos} {}
 
-    template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
+    template<typename Other>
+    requires !std::same_as<It, Other> && std::constructible_from<It, Other>
     constexpr dense_set_local_iterator(const dense_set_local_iterator<Other> &other) noexcept
         : it{other.it},
           offset{other.offset} {}

+ 3 - 2
src/entt/container/table.hpp

@@ -1,10 +1,10 @@
 #ifndef ENTT_CONTAINER_TABLE_HPP
 #define ENTT_CONTAINER_TABLE_HPP
 
+#include <concepts>
 #include <cstddef>
 #include <iterator>
 #include <tuple>
-#include <type_traits>
 #include <utility>
 #include "../config/config.h"
 #include "../core/iterator.hpp"
@@ -34,7 +34,8 @@ public:
     constexpr table_iterator(It... from) noexcept
         : it{from...} {}
 
-    template<typename... Other, typename = std::enable_if_t<(std::is_constructible_v<It, Other> && ...)>>
+    template<typename... Other>
+    requires (std::constructible_from<It, Other> && ...)
     constexpr table_iterator(const table_iterator<Other...> &other) noexcept
         : table_iterator{std::get<Other>(other.it)...} {}