typedef alternative

Jonathan M Davis jmdavisprog at gmail.com
Sat Aug 14 18:34:02 PDT 2010


On Saturday 14 August 2010 18:15:40 Yao G. wrote:
> On Sat, 14 Aug 2010 20:05:04 -0500, Jonathan M Davis
> 
> <jmdavisprog at gmail.com> wrote:
> > [snip]
> > 
> > Are you looking to create a new type that while technically identical to
> > another type is not considered the same as that type by the type system?
> > 
> > - Jonathan M Davis
> 
> Yes, This is exactly what I want. I need, for example, that if you pass a
> Year instance to the Month parameter, generate a compiler error.

Well, if you search the D list for typedef, you should find some posts that 
suggest templated structs combined with alias which get you typedefs. It sounds 
like something like that will probably end up in Phobos at some point, though 
apparently there are some issues with conversions (though what they would be if 
you're trying to keep the types completely separate, I don't know).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list