Problems using 'with' statement
Adam S
adamschwalm at gmail.com
Sat Jan 4 12:56:40 PST 2014
I've encountered an issue using the 'with' statement. Can anyone
explain why the following requires that I explicitly specify the
variable name, even though it is within a 'with'?
class Foo {
auto test(alias val)() if (is(typeof(val) == int)){}
auto test(alias val)() if (!is(typeof(val) == int)){}
}
void main() {
auto bar = new Foo;
with (bar) {
//test!2(); //fails to compile
//test!"cats"(); //fails to compile
bar.test!2(); //works
bar.test!"cats"(); //works
}
}
The commented out lines fail with:
Error: need 'this' for 'test' of type 'pure nothrow @safe
void()'
Thanks
More information about the Digitalmars-d-learn
mailing list