Thread overview |
---|
May 12, 2016 Is this template constraint a bug? | ||||
---|---|---|---|---|
| ||||
is(T : A!T) tells if T can automatically be converted to A!T. The last line below is doing just that, yet the template constraint does not work. class A(T) if (is(T : A!T)) { } // if (is(T : A!T)) gives this error: // Error: template instance x.A!(B) does not match // template declaration A(T) if (is(T : A!T)) // while looking for match for A!(B) class B : A!(B) { } void main(string[] args) { B b = new B(); A!B a = b; // compiles fine } -Eric |
May 12, 2016 Re: Is this template constraint a bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Eric | On Thursday, 12 May 2016 at 15:33:24 UTC, Eric wrote:
>
> is(T : A!T) tells if T can automatically be converted to A!T. The
> last line below is doing just that, yet the template constraint does not work.
>
> class A(T) if (is(T : A!T))
> {
> }
>
Yes, it's a bug. Please file an issue.
Meanwhile try this workaround:
class A(T)
{
static assert(is(T : A!T), "...");
}
|
May 12, 2016 Re: Is this template constraint a bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel N | >
> Yes, it's a bug. Please file an issue.
>
> Meanwhile try this workaround:
> class A(T)
> {
> static assert(is(T : A!T), "...");
> }
Bug report filed, and thanks for the workaround.
-Eric
|
Copyright © 1999-2021 by the D Language Foundation