[Issue 15623] is(M!N) evaluates to true for M!N that fails to instantiate.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jan 30 04:27:38 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15623
--- Comment #2 from Adrian Matoga <epi at atari8.info> ---
It's not only module scope - it's broken also inside templates, e.g.:
---
template canBeInstantiated(alias StructTemplate, Parameters...)
{
static if (is(StructTemplate!Parameters))
enum canBeInstantiated = true;
else
enum canBeInstantiated = false;
}
static assert( canBeInstantiated!(CallsFoo, HasFoo));
//static assert(!canBeInstantiated!(CallsFoo, NoFoo)); //fails
---
or:
---
template canBeInstantiated(alias StructTemplate, Parameters...)
{
enum canBeInstantiated = is(StructTemplate!Parameters);
}
static assert( canBeInstantiated!(CallsFoo, HasFoo));
//static assert(!canBeInstantiated!(CallsFoo, NoFoo)); //fails
---
However, the function trick indeed works:
---
bool canBeInstantiated(alias StructTemplate, Parameters...)()
{
return is(StructTemplate!Parameters);
}
static assert( canBeInstantiated!(CallsFoo, HasFoo));
static assert(!canBeInstantiated!(CallsFoo, NoFoo)); // hooray!
---
--
More information about the Digitalmars-d-bugs
mailing list