Use std::invocable<T&...>
This commit is contained in:
parent
006d9fc95e
commit
3aaa4557c6
2 changed files with 12 additions and 11 deletions
|
@ -139,7 +139,7 @@ TEST_CASE("Addresses of removed components should be reused")
|
|||
* Gotta reverse it because now we reuse ids in LIFO order
|
||||
*/
|
||||
std::reverse(addr.begin(), addr.end());
|
||||
|
||||
|
||||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
REQUIRE(&w.get<ChoosenOne>(entities[j]) == addr[j]);
|
||||
|
|
21
zecsy.hpp
21
zecsy.hpp
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <format>
|
||||
|
@ -8,9 +9,7 @@
|
|||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <concepts>
|
||||
|
||||
namespace zecsy
|
||||
{
|
||||
|
@ -22,14 +21,14 @@ namespace zecsy
|
|||
template<typename... T>
|
||||
concept Component = []
|
||||
{
|
||||
static_assert((std::is_default_constructible_v<T> && ...),
|
||||
"Should have a default constructor");
|
||||
static_assert((std::is_default_constructible_v<T> && ...),
|
||||
"Should have a default constructor");
|
||||
static_assert((std::is_trivially_copyable_v<T> && ...),
|
||||
"Should be trivially copyable");
|
||||
"Should be trivially copyable");
|
||||
static_assert((std::is_trivially_destructible_v<T> && ...),
|
||||
"Should be trivially destructible");
|
||||
static_assert((std::is_standard_layout_v<T> && ...),
|
||||
"Should have standard layout");
|
||||
"Should be trivially destructible");
|
||||
static_assert((std::is_standard_layout_v<T> && ...),
|
||||
"Should have standard layout");
|
||||
return true;
|
||||
}();
|
||||
|
||||
|
@ -213,6 +212,7 @@ namespace zecsy
|
|||
void add_system(int freq, auto&& func);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
private:
|
||||
struct system_handler
|
||||
{
|
||||
|
@ -273,7 +273,8 @@ namespace zecsy
|
|||
void remove(entity_id e);
|
||||
|
||||
template<Component... T>
|
||||
void query(auto&& system);
|
||||
void query(std::invocable<T&...> auto&& system);
|
||||
|
||||
private:
|
||||
entities_set alive_entities;
|
||||
entity_id entity_counter = 0;
|
||||
|
@ -328,7 +329,7 @@ namespace zecsy
|
|||
}
|
||||
|
||||
template<Component... T>
|
||||
inline void world::query(auto&& system)
|
||||
inline void world::query(std::invocable<T&...> auto&& system)
|
||||
{
|
||||
for(auto e: alive_entities)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue