Default struct constructor
Cym13
cpicard at openmailbox.org
Sun Feb 10 09:13:13 UTC 2019
On Friday, 8 February 2019 at 19:24:00 UTC, Victor Porton wrote:
> On Friday, 8 February 2019 at 19:20:59 UTC, psycha0s wrote:
>> What kind of problems a default struct constructor could
>> solve? If you want to use RAII, you need to pass the resource
>> as an argument. If you want to set some initial state, you can
>> do it by assigning values to the struct members directly.
>
> In my particular case I need RAII initializing a C library
> object. Some of the C constructor functions don't have
> arguments. So the only way to do it is my silly hack with Dummy
> object. I would probably vote for a change in D spec.
You might like this article
https://w0rp.com/blog/post/an-raii-constructor-by-another-name-is-just-as-sweet/
More information about the Digitalmars-d
mailing list