Arun Chandrasekaran wrote:
why not static method or free function that returns struct? due to NRVO[0] it won't even be copied.I'm trying to write an RAII wrapper on Linux.I understand struct in D doesn't have default constructor (for .init reasons).I don't want to use `scope`. Is there an elegant way to achieve this in D?
auto lock = MyWrapper();`MyWrapper()` may return voldemort type, so user won't create your struct accidentally.
[0] https://dlang.org/glossary.html#nrvo