Handling different types gracefully
Roderick Gibson
kniteli at gmail.com
Mon Jul 1 21:41:51 PDT 2013
On Monday, 1 July 2013 at 12:16:50 UTC, bearophile wrote:
> 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
Variant is a possiblity. How is the performance with large
containers of these, since these structures will likely hold the
majority of the data in the game?
> Waiting for multiple "alias this" ??
> And opDispatch to respond to unimplemented components.
I'm not sure what you mean by this.
More information about the Digitalmars-d-learn
mailing list