Using std.conv.to with std.typecons.Typedef
Saurabh Das via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 11 00:03:19 PST 2016
I am trying to create 2 types which contain integral values but
should not be compatible with each other. std.typecons.Typedef
seems perfect for this:
alias QuestionId = Typedef!(long, long.init, "QuestionId");
alias StudentId = Typedef!(long, long.init, "StudentId");
However I'm failing to use using std.conv.to:
QuestionId q = to!QuestionId("34"); <-- gives compile errors
(This is a reduced example, the actual use case is to use std.csv
to read in a structure from file, which in turn calls to!xyz)
How can I get std.conv to understand std.typecons.Typedef? In
general, is there a better solution to orthogonal types than
Typedef?
Thanks,
Saurabh
More information about the Digitalmars-d-learn
mailing list