Struct default constructor - need some kind of solution for C++ interop
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 7 04:41:28 PDT 2016
> static opCall() seems to be the only way to do this then. I can
> autogenerate it for any C++ bound class. But it's inadequate.
> It leaves room for user error when instantiating any C++ object
> in D. It's also another thing that C++ programmers need to be
> thoroughly educated about as Type() in C++11 calls the zero
> initializer, but in D it's effectively the opposite semantics.
Please try out everything possible instead of resorting to static
opCall. It is a terrible hack, both confusing and inconsistent
(won't apply if you allocate struct on heap) that got popular
simply because some devs were unhappy with language decision to
prohibit default ctors. It never makes sense to use it, literally
never.
More information about the Digitalmars-d
mailing list