Detecting if a class type (which may or may not have a defaultconstructor) is abstract

Jarrett Billingsley jarrett.billingsley at gmail.com
Thu Nov 13 16:10:29 PST 2008


On Thu, Nov 13, 2008 at 5:26 PM, BCS <ao at pathlink.com> wrote:
> Reply to Jarrett,
>
>> I just don't think it's possible.  If all classes had default ctors,
>> it'd be easy; is(typeof(new T)) would be false if and only if T were
>> abstract.  But since that's not the case, I can't think of a way to
>> generically see if a given class type is abstract.  Any ideas?
>>
>> It's always a little frustrating when doing type introspection and
>> having to rely on weird side-effects and properties of types, when the
>> compiler is just keeping it in some flag or field somewhere.  Sigh.
>> "is(T == abstract)"?  :P
>>
>
> _traits(isAbstractClass, Class) // 2.0 only IIRC

D1.


More information about the Digitalmars-d-learn mailing list