Mix struct types in the same array

Sebastiaan Koppe mail at skoppe.eu
Wed Dec 18 22:11:10 UTC 2019


On Wednesday, 18 December 2019 at 22:00:20 UTC, tirithen wrote:
> I want to have a array/list/queue of instances of various 
> struct types that represent events. How can I achieve that? 
> With classes I would have interfaces I guess, but I want to use 
> structs if possible as they seem less complex (and faster?).
>
> Can I wrap each struct with in another struct called something 
> like Entry that in turn can contain the event struct some how, 
> or will that just move the problem?

If you know all types up front you can use the Sumtype library on 
code.dlang.org


More information about the Digitalmars-d-learn mailing list