@disable this for structs

Namespace rswhite4 at googlemail.com
Thu Feb 27 17:32:26 PST 2014


On Friday, 28 February 2014 at 01:16:41 UTC, Mike Parker wrote:
> On 2/28/2014 3:10 AM, 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
>
> I use it for namespaces.
>
> struct Foo {
>    @disable this();
>    @disable this( this );
>
>    private static {
>       // members
>    }
>
>    public static {
>       // methods
>    }
> }
>
> Ideally, I'd love for the compiler to pick up on this idiom and 
> not generate any typeinfo in this situation.

For such namespaces I use final abstract classes:

final abstract class Foo {
static:
     // members
}


More information about the Digitalmars-d-learn mailing list