Enum of types
Diggory
diggsey at googlemail.com
Mon May 20 20:20:54 PDT 2013
I want to create an enum of some number of types, eg. { ubyte,
ushort, uint, float }
It should be straightforward to get a member of the enum from the
type itself. Basically I have an object that stores some typed
data, but the type may not be known at compile time, only the set
of possible types. When constructing the object the user should
be able to tell it what type of data it will hold. Also the
underlying type of the enum should be efficient to store and
compare.
So far the best I can come up with is using a mixin and CTFE to
generate the code for an enum plus a template function to convert
from a type to a member of the enum, but it seems like there
might be a better way?
More information about the Digitalmars-d-learn
mailing list