class MyClass(T) : Base if (ConstraintExpression) {} compilation error

Simen Kjaeraas simen.kjaras at gmail.com
Fri May 24 08:07:40 PDT 2013


On 2013-05-24, 16:49, ref2401 wrote:

> Version D 2.062
>
> Please explain what is causing the error
>
> class Base
> { }
>
> class Class(T) : Base
> if (is(T == int))
> { }
>
> Error: unrecognized declaration
> Error: members expected
> Error: Declaration expected, not 'if'
> Error: { } expected following aggregate declaration

I'm confused too. This works:

class Base
{ }

class Class(T)
if (is(T == int)) : Base
{ }

void foo() {
    Base a = new Class!int;
}

-- 
Simen


More information about the Digitalmars-d-learn mailing list