__traits(compiles,...) <=> ? is(typeof(...))
Zhenya
zheny at list.ru
Mon Oct 29 03:42:59 PDT 2012
Hi!
Tell me please,in this code first and second static if,are these
equivalent?
with arg = 1, __traits(compiles,"check(arg);") = true,
is(typeof(check(arg))) = false.
template ArgType(alias arg)
{
void check(T)(ref T t) {};
// static if(__traits(compiles,"check(arg);"))
static if(is(typeof(check(arg))))
{
struct ArgType
{
typeof(arg)* m_ptr;
this(ref typeof(arg) r)
{
m_ptr = &r;
}
@property ref typeof(arg) get()
{
return *m_ptr;
}
alias get this;
}
}
else
alias typeof(arg) ArgType;
}
More information about the Digitalmars-d-learn
mailing list