C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extend std::type_info with more information

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 8 Apr 2024 07:10:35 +0100
On Mon, Apr 8, 2024 at 6:47 AM Frederick Virchanza Gotham wrote:
>
> struct Base1 {};
> struct Base2 { virtual ~Base2(void){} };
> struct Base3 : Base2 {};
> struct Derived : Base1, Base3 {};
>
> Derived var;
> Base1 * p1 = &var;
> Base2 * p2 = &var;
> Base3 * p3 = &var;
>
> static_assert( false == typeid(*p1).is_polymorphic() );
> static_assert( true == typeid(*p1).is_polymorphic() );
> static_assert( true == typeid(*p1).is_polymorphic() );


Correction:
    Those static_assert's should be *p1, *p2, *p3.

Received on 2024-04-08 06:10:47