Use std::invocable<T&...>
This commit is contained in:
parent
006d9fc95e
commit
3aaa4557c6
2 changed files with 12 additions and 11 deletions
17
zecsy.hpp
17
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
|
||||
{
|
||||
|
@ -23,13 +22,13 @@ namespace zecsy
|
|||
concept Component = []
|
||||
{
|
||||
static_assert((std::is_default_constructible_v<T> && ...),
|
||||
"Should have a default constructor");
|
||||
"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");
|
||||
"Should be trivially destructible");
|
||||
static_assert((std::is_standard_layout_v<T> && ...),
|
||||
"Should have standard layout");
|
||||
"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