Named constructors

Dru dru at notreal.com
Thu Jan 10 13:44:52 UTC 2019


> Here is the one without templates
>
>
> struct Stuff_Normal {}
> struct Stuff_Special {}
>
> struct Stuff
> {
>
>   this(Stuff_Normal _, float x, float y) { ... }
>   this(Stuff_Special _, float x, float y) { ... }
> }
>
> usage
>
>   auto val = Stuff(Stuff_Normal(), 1, 2);

Not pretty syntax but I think this is the most practical solution 
:)



More information about the Digitalmars-d mailing list