Tuple/Typedef question

Martin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 11 03:41:08 PST 2015


Is there a way to get Tuple (and Typedef) from the std.typecons
module to generate a new type that is unique on every
instantiation? What I mean is:

alias T1 = Tuple!(int, int);
alias T2 = Tuple!(int, int);

writeln(__traits(isSame, T1, T2)); // prints true

When using Typedef, the types are still the same:

alias T1New = Typedef!(T1);
alias T2New = Typedef!(T2);

writeln(__traits(isSame, T1New, T2New)); // still prints true

The documentation of Typedef says:
"Typedef allows the creation of a unique type which is based on
an existing type. Unlike the alias feature, Typedef ensures the
two types are not considered as equals."

Shouldn't the second part at least print false then?


More information about the Digitalmars-d-learn mailing list