[Issue 12120] Static opCall for structures skipped (Github HEAD)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 9 18:04:53 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12120
--- Comment #3 from Puneet Goel <puneet at coverify.org> 2014-02-09 18:04:52 PST ---
>
> If you define constructors in a struct, the syntax `Type()` should be reserved
> for default construction.
>
> If you want to support both Foo() and Foo(1), you should change the constructor
> to static Foo opCall(int).
I am sorry if I missed something, but how do I initialize a struct object
element from a call to Foo()? I believe default constructors are not allowed
for structs.
Say:
class Bar {}
struct Foo {
Bar bar; // bar is not static
static Foo opCall() {
// I want to return a Foo object with bar initialized
// How can I achieve that??
}
this() { // Does not compile
bar = new Bar();
}
}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list