Den 19-06-2011 19:42, David Nadlinger skrev:
On 6/19/11 7:34 PM, jdrewsen wrote:
I guess that I can initialize variables in the opCall and that way the
user should not have to remember to initialize variables?

Yes, you can just do:

---
struct Foo {
Foo static opCall() {
Foo result;
result.<whatever> = <somevalue>;
return result;
}
…
}
---

The thing is that the static opCall is not invoked if the user writes
»Foo foo;« instead of »auto foo = Foo();«, so you need to carefully
document that users need to use the opCall syntax.

This shouldn't be a problem really since the struct is private.

/Jonas

Reply via email to