Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions spec/traits.dd
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,30 @@ static assert(__traits(isSame, object, object));
alias daz = foo;
static assert(__traits(isSame, foo, daz));
---
)
$(P isSame will also match template symbols as well as types.)

$(SPEC_RUNNABLE_EXAMPLE_COMPILE
---
struct Foo(T){
T x;
}

struct Bar(T){
T x;
}

struct Point(T){
T x;
T y;
}

enum isFooOrBar(alias FB) = __traits(isSame, FB, Foo) || __traits(isSame, FB, Bar);

static assert(isFooOrBar!(Foo));//true
static assert(isFooOrBar!(Bar));//true
static assert(isFooOrBar!(Point));//false
---
)

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