Explorar o código

added exclude alias for type_list

Michele Caini %!s(int64=7) %!d(string=hai) anos
pai
achega
ebb2974ca7
Modificáronse 4 ficheiros con 10 adicións e 3 borrados
  1. 0 1
      TODO
  2. 1 1
      docs/entity.md
  3. 8 0
      src/entt/core/type_traits.hpp
  4. 1 1
      test/entt/entity/view.cpp

+ 0 - 1
TODO

@@ -20,5 +20,4 @@
 * mention hunter in the readme file, section packaging tools
 * travis + windows is now available, try it
 * events on replace, so that one can track updated components? indagate impact
-* add entt::exclude as alias of entt::type_list
 * add sparse_set::swap and registry::swap

+ 1 - 1
docs/entity.md

@@ -1037,7 +1037,7 @@ auto view = registry.persistent_view<position, velocity>();
 Filtering entities by components is also supported:
 
 ```cpp
-auto view = registry.persistent_view<position, velocity>(entt::type_list<renderable>);
+auto view = registry.persistent_view<position, velocity>(entt::exclude<renderable>);
 ```
 
 In this case, the view will return all the entities that have both components

+ 8 - 0
src/entt/core/type_traits.hpp

@@ -34,6 +34,14 @@ constexpr auto type_list_cat(type_list<Type...>, type_list<Other...>, List...) {
 }
 
 
+/**
+ * @brief Alias template for type lists.
+ * @tparam Type List of types.
+ */
+template<typename... Type>
+using exclude = type_list<Type...>;
+
+
 }
 
 

+ 1 - 1
test/entt/entity/view.cpp

@@ -279,7 +279,7 @@ TEST(PersistentView, ExcludedComponents) {
     registry.assign<int>(e1, 1);
     registry.assign<char>(e1);
 
-    const auto view = registry.persistent_view<int>(entt::type_list<char>{});
+    const auto view = registry.persistent_view<int>(entt::exclude<char>{});
 
     const auto e2 = registry.create();
     registry.assign<int>(e2, 2);