C++ Logo

std-proposals

Advanced search

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

From: F. v.S. <de34_at_[hidden]>
Date: Tue, 23 Apr 2024 08:38:05 +0000
I roughly read the proposal and found some weirdness in it.

1. operator==​ should be specified instead of operator!=​. As of C++20 there're rewritten candidates.
2. The bases()​ member function should return a range, not a pair​. It's sad story that equal_range​ member functions of containers don't return ranges and we can't fix them. Perhaps it's still possible to fix flat container adaptors with a defect report at this moment.


Thanks,
F.v.S.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Sunday, April 7, 2024 21:35
To: std-proposals <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_gmail.com>
Subject: [std-proposals] Extend std::type_info with more information

We need more information in std::type_info, such as the 'sizeof' and
'alignof' of a type, and also if it's polymorphic. We could probably
do with a few more pieces of information too (Is it a pointer? Is it
an integer type?).

Here's a very early draft paper just to stir conversation:

    http://www.virjacode.com/papers/extend_type_info.htm

I'm looking at the Itanium ABI spec here . . . and I'll look closer
over the coming days but I can't see the 'sizeof' nor the 'alignof'
anywhere, so I don't know how much extra info we can garner here???

If an ABI break is inevitable then we might even need an
"std::typeid_extended" which returns a "std::type_info_extended".

By the way... while I'm typing away here. . . since you need to
include the <typeinfo> header in order to use the 'typeid' operator,
would it not have made more sense to have had a standard library
function instead of an operator, as follows:

namespace std {
  template<typename T>
  constexpr type_info const &typeid(void) noexcept;
}

And so then you would have done:

   auto const &ti = std::typeid<MyClass>();

The ship has sailed but anyway.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-04-23 08:38:12