clear()

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 9 12:00:07 PDT 2009


Jacob Carlborg wrote:
> On 10/9/09 18:40, Andrei Alexandrescu wrote:
>> I'm talking with Sean and Walter about taking the first step towards
>> eliminating delete: defining function clear() that clears the state of
>> an object. Let me know of what you think.
>>
>> One problem I encountered is that I can't distinguish between a default
>> constructor that doesn't need to exist, and one that was disabled
>> because of other constructors. Consider:
>>
>> class A {}
>> class B { this(int) {} }
>>
>> You can evaluate "new A" but not "new B". So it's legit to create
>> objects of type A all default-initialized. But the pointer to
>> constructor stored in A.classinfo is null, same as B.
>>
>> Any ideas?
>>
>>
>> Andrei
> 
> How about this:
> 
> static if (is(typeof({
>         auto t = new T;
>     })))

I'm in awe. Thanks, Jacob!!!

Andrei



More information about the Digitalmars-d mailing list