@disable this for structs

John Colvin john.loughran.colvin at gmail.com
Thu Feb 27 10:36:20 PST 2014


On Thursday, 27 February 2014 at 18:26:10 UTC, Steve Teale wrote:
> On Thursday, 27 February 2014 at 18:13:43 UTC, Namespace wrote:
>> On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale 
>> wrote:
>>> Could someone please explain what you would use this for to 
>>> an old man rooted in C++, but who loves D.
>>>
>>> Where does it fit in relative to 42?
>>>
>>> ;=(
>>>
>>> Steve
>>
>> It's for explicit initialization:
>>
>> struct Foo { }
>>
>> Foo f; // no problem
>>
>> struct Bar {
>>    @disable this();
>> }
>>
>> Bar b; // error
>
> So it is just a reminder that you need to initialize Bar in 
> some specific way?

pretty much, yes.

More precisely, it disables the implicit no-op default 
constructor, forcing the user to use a different one.


More information about the Digitalmars-d-learn mailing list