New template problem
Steven Schveighoffer
schveiguy at yahoo.com
Mon May 19 09:46:33 PDT 2008
"bearophile" wrote
> 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?
Any reason why you use HasLength!(typeof(new Foo)) vs HasLength!(Foo)?
-Steve
More information about the Digitalmars-d-learn
mailing list