C++ Logo

std-proposals

Advanced search

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

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 11 Apr 2024 11:35:46 +0000

> Step 1 of implementing it is to be able to see all of the base classes of the Derived type at runtime having only its type_info. So I propose adding a new method called 'bases' to std::type_info. At first I thought this new method should return a pointer to a null-terminated array of pointers to type_info's, as follows:

No! You just define it in the standard that std::any should have a conversion that allows to get a pointer to base even if the object contained in std::any is derived.
How that is achieved is implementation detail left for library implementers to do it in away that is efficient for their specific platform. And they will be able to account for all the nuances of their specific platform in their implementation, which won't require to change type_info, because a system already exists to handle RTTI for exceptions (which already exists and doesn't require this).

Again, the "how" is the wrong thing here, it’s a trivial non-issue. The "why" is the problem.

Received on 2024-04-11 11:35:49