C++'s this() equivalent?

Steven Schveighoffer schveiguy at gmail.com
Fri Jun 16 01:00:05 UTC 2023


On 6/15/23 8:52 PM, zjh wrote:
> On Friday, 16 June 2023 at 00:35:48 UTC, Steven Schveighoffer wrote:
> 
>> Instead, you can use factory functions to initialize.
>>
> 
> How can `factory functions` be used to achieve effects similar to `'RAII'`?
> Thank you.
> 

B b;

becomes

B b = B.make(); // call factory function

All my uses of RAII depend on copy construction and destruction. 
Construction is easy enough because I have to explicitly declare it anyway.

-Steve


More information about the Digitalmars-d-learn mailing list