Templated Struct Constructors

Andrew Wiley wiley.andrew.j at gmail.com
Wed Dec 21 21:59:43 PST 2011


Is this a bug, or are templated struct constructors not allowed to
call other constructors?

---
struct A {
    this(T)(T thing, int i) {
        this(thing, i > 0); // Error: constructor call must be in a constructor
    }
    this(T)(T thing, bool b) {
    }
}

void main() {
    auto a = A(5, 5); // Error: template instance
constructtest.A.__ctor!(int) error instantiating
}
---


More information about the Digitalmars-d mailing list