digitalmars.D.learn - New template problem
- bearophile <bearophileHUGS lycos.com> May 18 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> May 19 2008
- bearophile <bearophileHUGS lycos.com> May 19 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
May 18 2008
"bearophile" wroteAfter 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
May 19 2008
Steven Schveighoffer:Any reason why you use HasLength!(typeof(new Foo)) vs HasLength!(Foo)?
Nope. (I have reverted to DMD 1.029 because 1.030 doesn't work for me, so I can't tell you if your version too produces the bug). Bye and thank you, bearophile
May 19 2008








bearophile <bearophileHUGS lycos.com>