Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
deadalnix
deadalnix at gmail.com
Sun May 19 10:41:43 PDT 2013
On Sunday, 19 May 2013 at 04:57:15 UTC, Walter Bright wrote:
> On 5/18/2013 8:54 PM, deadalnix wrote:
>> On Sunday, 19 May 2013 at 01:20:31 UTC, Walter Bright wrote:
>>> I understand that. But the rationale you gave for having a
>>> default constructor
>>> was to be able to disable default construction.
>>
>> RAII or construction based on template parameters.
>
> I know what default constructors are used for in C++. That
> wasn't what I asked, though. I asked for compelling rationale.
>
I have bunch of code that goes like :
auto oldVar = var;
scope(exit) var = oldVar;
This is begging for a RAII solution where I pass var as template
parameter but would require default constructor. This is an
actual problem I have right now as all save/restore are harder
and harder to keep in sync for no reason and generate a lot of
boilerplate.
This is a problem I have right now that default constructor would
solve, and this isn't the first time I hit that need.
More information about the Digitalmars-d
mailing list