C++ Logo

std-proposals

Advanced search

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

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Mon, 8 Apr 2024 08:29:20 +0200
On 08/04/2024 07.47, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Sun, Apr 7, 2024 at 9:19 PM Jens Maurer wrote:
>>
>> struct Base { };
>> struct Derived {};
>
> I'm guessing you meant
>
> struct Derived : Base {};

Yes.

>> int f(Base * b) { // not a template
>> typeid(*b); // yields std::type_info object for "Derived"
>> return 0;
>> }
>>
>> int x = f(new Derived);
>
>
> With regard to the member function std::type_info::is_polymorphic

I wasn't asking about this. I was specifically asking about the
idea that, instead of a built-in operator "typeid", we should just
have a template get_type_id<T>

Jens

Received on 2024-04-08 06:29:24