On Mon, 26 Sep 2011 17:14:45 +0100, Jonathan M Davis <[email protected]>
wrote:
On Monday, September 26, 2011 09:01:20 Mehrdad wrote:
On 9/26/2011 8:13 AM, Trass3r wrote:
> Your opCall isn't static.
Yeah, I don't want it to be. I want to use opCall on an instance, not on
the type.
Well, it looks like having declared a non-static opCall makes the
automatically generated constructor for the struct unusable - which may
or may
not be a bug (there are similar issues with declaring opCast). If you
just
declare a constructor, it should solve the problem.
I couldn't get that to work.. but this does:
import std.stdio;
struct Adder {
int v;
auto opCall(int x) { return x + v; }
}
auto adder(int v) {
Adder a;
a.v = v;
return a;
}
void main() {
auto a = adder(5);
writefln("%s", a(5));
}
--
Using Opera's revolutionary email client: http://www.opera.com/mail/