C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::type_info::size()

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 1 Aug 2023 21:52:03 +0100
On Mon, Jul 31, 2023 at 4:48 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> What's more, changing this is a full-on language ABI break because it adds a
> new field that isn't there in the type_info. That means the impact of *adding*
> this now is extremely high, equal to replacing std:: with std2.


Ok then here's a compromise to prevent ABI breakage: If you don't put
it inside the 'type_info' object, then at least provide a way of
retrieving it from any 'type_info' object, as follows:

    namespace std {
        size_t typeinfo_sizeof (type_info const &);
        size_t typeinfo_alignof(type_info const &);
    };

    int main(void)
    {
        std::type_info const &ti = typeid( SomeClass );

        cout << "Alignment of SomeClass: " << typeinfo_alignof(ti) << endl;
    }

If you're worried about the overhead then compilers can have a switch
"-fno-extended-typeinfo".

Received on 2023-08-01 20:52:16