瀏覽代碼

core/entity: enable enable_borrowed_range/enable_view for a few types - close #1119

Michele Caini 1 年之前
父節點
當前提交
da8a8650cb
共有 5 個文件被更改,包括 45 次插入0 次删除
  1. 2 0
      CMakeLists.txt
  2. 1 0
      entt.imp
  3. 17 0
      src/entt/core/ranges.hpp
  4. 23 0
      src/entt/entity/ranges.hpp
  5. 2 0
      src/entt/entt.hpp

+ 2 - 0
CMakeLists.txt

@@ -132,6 +132,7 @@ if(ENTT_INCLUDE_HEADERS)
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/iterator.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/memory.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/monostate.hpp>
+            $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/ranges.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/tuple.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/type_info.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/type_traits.hpp>
@@ -145,6 +146,7 @@ if(ENTT_INCLUDE_HEADERS)
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/helper.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/observer.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/organizer.hpp>
+            $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/ranges.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/registry.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/runtime_view.hpp>
             $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/snapshot.hpp>

+ 1 - 0
entt.imp

@@ -22,6 +22,7 @@
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/mixin.hpp>", "public" ] },
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/observer.hpp>", "public" ] },
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/organizer.hpp>", "public" ] },
+  { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/ranges.hpp>", "public" ] },
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/registry.hpp>", "public" ] },
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/runtime_view.hpp>", "public" ] },
   { "include": [ "@[\"<].*/entity/fwd\\.hpp[\">]", "private", "<entt/entity/snapshot.hpp>", "public" ] },

+ 17 - 0
src/entt/core/ranges.hpp

@@ -0,0 +1,17 @@
+#ifndef ENTT_ENTITY_RANGES_HPP
+#define ENTT_ENTITY_RANGES_HPP
+
+#if __cplusplus >= 202002L
+
+#    include <ranges>
+#    include "iterator.hpp"
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_borrowed_range<entt::iterable_adaptor<Args...>>{true};
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_view<entt::iterable_adaptor<Args...>>{true};
+
+#endif
+
+#endif

+ 23 - 0
src/entt/entity/ranges.hpp

@@ -0,0 +1,23 @@
+#ifndef ENTT_ENTITY_RANGES_HPP
+#define ENTT_ENTITY_RANGES_HPP
+
+#if __cplusplus >= 202002L
+
+#    include <ranges>
+#    include "fwd.hpp"
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_borrowed_range<entt::basic_view<Args...>>{true};
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_borrowed_range<entt::basic_group<Args...>>{true};
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_view<entt::basic_view<Args...>>{true};
+
+template<class... Args>
+inline constexpr bool std::ranges::enable_view<entt::basic_group<Args...>>{true};
+
+#endif
+
+#endif

+ 2 - 0
src/entt/entt.hpp

@@ -16,6 +16,7 @@
 #include "core/iterator.hpp"
 #include "core/memory.hpp"
 #include "core/monostate.hpp"
+#include "core/ranges.hpp"
 #include "core/tuple.hpp"
 #include "core/type_info.hpp"
 #include "core/type_traits.hpp"
@@ -28,6 +29,7 @@
 #include "entity/mixin.hpp"
 #include "entity/observer.hpp"
 #include "entity/organizer.hpp"
+#include "entity/ranges.hpp"
 #include "entity/registry.hpp"
 #include "entity/runtime_view.hpp"
 #include "entity/snapshot.hpp"