Thread overview | |||||
---|---|---|---|---|---|
|
May 24, 2013 class MyClass(T) : Base if (ConstraintExpression) {} compilation error | ||||
---|---|---|---|---|
| ||||
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 |
May 24, 2013 Re: class MyClass(T) : Base if (ConstraintExpression) {} compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to ref2401 | 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 |
May 24, 2013 Re: class MyClass(T) : Base if (ConstraintExpression) {} compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to ref2401 | On Friday, 24 May 2013 at 14:49:24 UTC, 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
because dmd acts as grammar nazi:
ClassTemplateDeclaration: class Identifier ( TemplateParameterList ) Constraintopt BaseClassListopt ClassBody
|
Copyright © 1999-2021 by the D Language Foundation