Skip to content

Commit 9123c6b

Browse files
Nils Lankiladlang-bot
authored andcommitted
Improve specs for __traits(isSame) over two tuples
Related bug fix dlang/dmd#11373
1 parent f7d46e7 commit 9123c6b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spec/traits.dd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,29 @@ void main()
15131513
static assert(!__traits(isSame, (A a) => ++a.a, (B a) => ++a.a));
15141514
}
15151515
---
1516+
)
1517+
1518+
$(P If the two arguments are tuples then `isSame` returns `true` if the
1519+
two tuples, after expansion, have the same length and if each pair
1520+
of nth argument respects the constraints previously specified.)
1521+
1522+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1523+
---
1524+
import std.stdio;
1525+
import std.meta;
1526+
1527+
struct S { }
1528+
1529+
void main()
1530+
{
1531+
// true, like __traits(isSame(0,0)) && __traits(isSame(1,1))
1532+
writeln(__traits(isSame, AliasSeq!(0,1), AliasSeq!(0,1)));
1533+
// false, like __traits(isSame(S,std.meta)) && __traits(isSame(1,1))
1534+
writeln(__traits(isSame, AliasSeq!(S,1), AliasSeq!(std.meta,1)));
1535+
// false, the length of the sequences is different
1536+
writeln(__traits(isSame, AliasSeq!(1), AliasSeq!(1,2)));
1537+
}
1538+
---
15161539
)
15171540

15181541
$(H2 $(GNAME compiles))

0 commit comments

Comments
 (0)