is(some template instantiation) is true, but the actual instantiation fails
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 29 15:44:56 PST 2016
On Friday, 29 January 2016 at 17:01:46 UTC, Adrian Matoga wrote:
> On Friday, 29 January 2016 at 16:36:01 UTC, Steven
> Schveighoffer wrote:
>> On 1/29/16 10:28 AM, Adrian Matoga wrote:
>>>[...]
>>
>> is(T) is supposed to be false if T is not a valid type.
>>
>> I would agree with you that the static assert should fail.
>>
>> -Steve
>
> Oh, there's more:
> // this should fail:
> static assert(is(CallsFoo!NoFoo));
> // this should fail too:
> static assert(is(typeof({ alias Baz = CallsFoo!NoFoo; return
> Baz.init; }())));
> // and this:
> static assert(__traits(compiles, { alias Baz = CallsFoo!NoFoo;
> return Baz.init; }()));
> // but only this fails:
> alias Baz = CallsFoo!NoFoo;
>
> https://issues.dlang.org/show_bug.cgi?id=15623
Haven't you seen my answer about constraint ?
If you put a constraint on your function template then invalid
instantiations are rejected. I mean... this language feature is
not just ornamental...
What do you think constraints are used for otherwise ^^
More information about the Digitalmars-d-learn
mailing list