Const Tuples
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 25 06:44:37 PDT 2014
On Friday, 25 April 2014 at 11:51:48 UTC, bearophile wrote:
> They are not the same type:
>
>
> void main() {
> import std.typecons: Tuple;
> alias T1 = const Tuple!(int, int);
> alias T2 = Tuple!(const int, const int);
> static assert(is(T1 == T2)); // Fails.
> }
>
>
> This type difference causes some troubles when you use tuples.
>
> Bye,
> bearophile
I think it's a bad idea to make these equal for this reason: if
T1 == T2, then you would expect Unqual!T1 == Unqual!T2. However:
alias T1 = const Tuple!(int, int);
alias T2 = Tuple!(const int, const int);
assert(is(T1 == T2));
alias UnT1 = Unqual!T1; // Tuple!(int, int)
alias UnT2 = Unqual!T2; // Tuple!(const int, const int)
assert(is(UnT1 == UnT2));
More information about the Digitalmars-d-learn
mailing list