[Issue 6036] Constructor, static opCall and object opCall
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 6 11:20:32 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036
--- Comment #11 from bearophile_hugs at eml.cc 2012-10-06 11:08:35 PDT ---
(In reply to comment #5)
> struct Adder {
> int v;
> auto opCall(int x) { return x + v; }
> }
>
> auto adder(int v) {
> return Adder(v); // How do I call the constructor??
> }
>
> int main() {
> auto a = adder(5);
> }
A little reduced:
struct Adder {
int v;
int opCall(int x) { return x + v; }
}
void main() {
auto a = Adder(5);
}
It gives:
temp.d(6): Error: need 'this' for opCall type int(int x)
Is it expected that the instance opCall disables the implicitly created struct
ctor?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list