digitalmars.D.learn - class MyClass(T) : Base if (ConstraintExpression) {} compilation error
- ref2401 (11/11) May 24 2013 Version D 2.062
- Simen Kjaeraas (12/23) May 24 2013 I'm confused too. This works:
- Maxim Fomin (4/15) May 24 2013 because dmd acts as grammar nazi:
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
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 declarationI'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
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 declarationbecause dmd acts as grammar nazi: ClassTemplateDeclaration: class Identifier ( TemplateParameterList ) Constraintopt BaseClassListopt ClassBody
May 24 2013