New template problem

bearophile bearophileHUGS at lycos.com
Sun May 18 15:06:21 PDT 2008


After a painful search I have found a new bug in my libs, that comes out using DMD 1.030 (with 1.029 the following code works):

template HasLength(T) {
    // const bool HasLength = is(typeof(T.length)) || is(typeof(T.init.length));
    const bool HasLength = is(typeof(T.length));
}

void main() {
    class Foo { int length; }
    //assert(!HasLength!(typeof( new Foo )));
    assert(!HasLength!(typeof( new Foo )));
}

Output (DMD 1.030):
Error: this for length needs to be type Foo not type int

Do you have some workaround/suggestion?
Bye,
bearophile


More information about the Digitalmars-d-learn mailing list