No we should not support enum types derived from strings
deadalnix
deadalnix at gmail.com
Wed May 12 15:35:26 UTC 2021
On Wednesday, 12 May 2021 at 14:52:42 UTC, Ola Fosheim Grøstad
wrote:
> On Tuesday, 11 May 2021 at 21:36:46 UTC, Andrei Alexandrescu
> wrote:
>> Values are monomorphic. Years ago I found a bug in a large C++
>> system that went like this:
>>
>> class Widget : BaseWidget {
>> ...
>> Widget* clone() {
>> assert(typeid(this) == typeid(Widget*));
>> return new Widget(*this);
>> }
>> };
>>
>> The assert was a _monomorphism test_, i.e. it made sure that
>> the current object is actually a Widget and not something
>> derived from it, who forgot to override clone() once again.
>
> I don't understand what you mean by pointers being monomorphic.
>
Ok, consider the following.
class A {};
class B: public A {};
A *a = new B();
tyepid(a) is A*. In C++, a is monomorphic.
typeid(*a) is B. In C++, *a is polymorphic.
More information about the Digitalmars-d
mailing list