clear()
Michel Fortin
michel.fortin at michelf.com
Fri Oct 9 12:44:07 PDT 2009
On 2009-10-09 15:01:30 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
>>> static if (is(typeof({
>>> auto t = new T;
>>> })))
>>
>> I'm in awe. Thanks, Jacob!!!
>>
>> Andrei
>
> Oh, wait, that doesn't work:
>
> class A {}
> class B : A { this(int) {} }
>
> A a = new B;
> clear(a); // oops
It would work, but only as a (virtual) member function redefined for
every subclass. Much like a 'clone' method. Sufficient runtime
reflection could work too to aleviate that, but it'd execute slower.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list