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

Reply via email to