On 11/10/2013 05:03 PM, Tommi wrote:
On Sunday, 10 November 2013 at 23:43:21 UTC, TheFlyingFiddle wrote:
The template isInstanceOf checks to see if the second parameter is a
template instantiation of the first parameter.
But in this example of mine:
isInstanceOf!(SuperSt, SubSt)
...the second parameter is not a template instantiation of the first
parameter, yet isInstanceOf evaluates to true.
I think what this all boils down to is that this is a compiler-bug:
struct A(T)
{}
struct B
{
A!int _a;
alias _a this;
}
void main()
{
static assert(!is(B == A!int)); // OK
static assert(is(B == A!T, T)); // BUG (shouldn't compile)
}
The compiler magically deduces T as int:
struct A(T)
{}
struct B
{
A!int _a;
alias _a this;
}
void main()
{
static if (is(B == A!T, T)) {
pragma(msg, T); // prints int
}
}
Ali