Skip to content

Commit c1df168

Browse files
authored
Merge pull request #4165 from chibisi/master
Update traits.dd Signed-off-by: Richard (Rikki) Andrew Cattermole <[email protected]> Merged-on-behalf-of: Nicholas Wilson <[email protected]>
2 parents 3773635 + 92467cb commit c1df168

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/traits.dd

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,30 @@ static assert(__traits(isSame, object, object));
19301930
alias daz = foo;
19311931
static assert(__traits(isSame, foo, daz));
19321932
---
1933+
)
1934+
$(P isSame matches against non-instantiated templates.)
1935+
1936+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1937+
---
1938+
struct Foo(T){
1939+
T x;
1940+
}
1941+
1942+
struct Bar(T){
1943+
T x;
1944+
}
1945+
1946+
struct Point(T){
1947+
T x;
1948+
T y;
1949+
}
1950+
1951+
enum isFooOrBar(alias FB) = __traits(isSame, FB, Foo) || __traits(isSame, FB, Bar);
1952+
1953+
static assert(isFooOrBar!(Foo));
1954+
static assert(isFooOrBar!(Bar));
1955+
static assert(!isFooOrBar!(Point));
1956+
---
19331957
)
19341958

19351959
$(P The result is `true` if the two arguments are expressions

0 commit comments

Comments
 (0)