C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 31 Jul 2023 08:48:15 -0700
On Monday, 31 July 2023 06:34:58 PDT Frederick Virchanza Gotham via Std-
Proposals wrote:
> I just realised today that you can't get the size of a type from its
> type_info.
>
> Really. . . . . . . ?
>
> Surely we should be able to do:
>
> void Func(std::type_info const &ti)
> {
> cout << ti.size() << endl;
> }

That sounds reasonable, but is it? As Sebastian said, it would incur overhead
for every single type whose typeinfo is generated. How often is this needed?
Are there any workarounds?

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.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-07-31 15:48:17