Haven't looked that far ahead at std::any either, so am not sure if it does or not. That being said, I guess it wouldn't be too difficult to come up with some function overloads to work that out...maybe?
I'm not very confident after what I've gone through with this damned variant ECS system. You really have to understand how the compiler sees things when dealing with concrete types and templates. For instance:
Code: Select all
using world_t = std::variant< // World variant
screws::ECS_World<
std::variant< // System variant
screws::ECS_System< // Movable system
MovableDispatcher,
MovableMessageHandler,
std::variant< // Entity variant
screws::ECS_Entity<player_tag, component_t>,
screws::ECS_Entity<enemy_tag, component_t>>,
std::variant< // Message variant
screws::ECS_Message<componentAdded_tag>,
screws::ECS_Message<componentRemoved_tag>,
screws::ECS_Message<entityAdded_tag>,
screws::ECS_Message<entityRemoved_tag>,
screws::ECS_Message<systemAdded_tag>,
screws::ECS_Message<systemRemoved_tag>>,
SystemMessageFilter>,
screws::ECS_System< // Draw system
DrawableDispatcher,
DrawableMessageHandler,
std::variant< // Entity variant
screws::ECS_Entity<player_tag, component_t>,
screws::ECS_Entity<enemy_tag, component_t>>,
std::variant< // Message variant
screws::ECS_Message<componentAdded_tag>,
screws::ECS_Message<componentRemoved_tag>,
screws::ECS_Message<entityAdded_tag>,
screws::ECS_Message<entityRemoved_tag>,
screws::ECS_Message<systemAdded_tag>,
screws::ECS_Message<systemRemoved_tag>>,
SystemMessageFilter>>,
std::variant< // Message variant
screws::ECS_Message<componentAdded_tag>,
screws::ECS_Message<componentRemoved_tag>,
screws::ECS_Message<entityAdded_tag>,
screws::ECS_Message<entityRemoved_tag>,
screws::ECS_Message<systemAdded_tag>,
screws::ECS_Message<systemRemoved_tag>>,
WorldMessageFilter>>;
So far, this is the only way I've gotten the project to compile. Using aliases was a nightmare to get the compiler to understand what I wanted. The issues I am having are the order in which things are seen and instantiated by the compiler.
I'd define an alias, but the type being aliased needed other long templated types, so I tried aliasing those types and found they needed to be defined somewhere before that because instantiating a template requires the type to be fully formed first, and so on.
In the end, I'm not finding variant to be a viable option for an ECS system even if ECS systems are suppose to be modular and not coupled, the fact that variant requires fully defined types before hand makes this decoupling a very difficult chore.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com