http://d.puremagic.com/issues/show_bug.cgi?id=9078
--- Comment #2 from Kenji Hara <[email protected]> 2013-04-03 23:30:10 PDT --- (In reply to comment #0) [snip] > A non-static opCall is chosen instead of a default constructor. > The non-static opCall() overloads should not interfere with construction. Currently function overload resolution does not consider whether the function is static or not (just one exception of the rule is constructor call). For example, function overloading based on static attribute does not work. struct S { void foo() {} static void foo() {} } void main() { S s; s.foo(); // error S.foo(); // error } So, A(42) always invokes opCall, and fails to compile. ------ There is two workarounds. 1. define proper constructor struct A { int i; this(int i) { this.i = i; } void opCall(int i) {} } void main() { auto a = A(42); // OK } 2. Use struct initializer for construction struct A { int i; void opCall(int i) {} } void main() { A a = {42}; // OK a(42); // invoke opCall } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
