Handling different types gracefully
bearophile
bearophileHUGS at lycos.com
Mon Jul 1 05:16:49 PDT 2013
Roderick Gibson:
> auto entities = new Entities();
> auto entity_id = entities.createEntity();
> entities.addComponent!(position)(entity_id, pos);
> entities.addComponent!(movement)(entity_id, mov);
> entities.addComponent!(collision)(entity_id, col);
> auto physics_data =
> entities.getEntitiesWithComponents!(position, movement,
> collision)();
>
> The two big requirements are some kind of regular, queryable
> structure to hold the components (of different types), and the
> ability to filter by type. Is anything like that remotely
> possible?
If the possible types are know, then there's
std.variant.Algebraic, otherwise there is a free Variant or
VariantN. They are not perfect, but maybe they are good enough
for you.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list