C++ Logo


Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 15 Apr 2024 07:45:39 +0100
On Mon, Apr 15, 2024 at 7:37 AM Frederick Virchanza Gotham wrote:
> I'm just floating this idea here to see what people are interested in
> having inside an 'extended_type_info', because at the moment
> 'type_info' is very sparse.

Just as an example, for debugging, it might be useful to have a
'print' function to print the object to an 'ostream':

        class std::extended_type_info {
            void (*print)(void const *p, std::ostream &o);
            . . .
            . . .

        template<typename T>
        extended_type_info get_type_info(void) noexcept
            extended_type_info eti;
            eti.print = [](void const *const p, std::ostream &o){ o <<
*(T const*)p; };
            return eti;

Received on 2024-04-15 06:45:51