Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions stl/inc/typeindex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#if _HAS_CXX20
#include <compare>
#include <cstring>
#endif // _HAS_CXX20

#pragma pack(push, _CRT_PACKING)
Expand Down Expand Up @@ -40,9 +41,12 @@ public:

#if _HAS_CXX20
_NODISCARD strong_ordering operator<=>(const type_index& _Right) const noexcept {
return *_Tptr == *_Right._Tptr ? strong_ordering::equal
: _Tptr->before(*_Right._Tptr) ? strong_ordering::less
: strong_ordering::greater;
// TRANSITION, DevCom-10326599, should rely on a stable interface
if (_Tptr == _Right._Tptr) {
return strong_ordering::equal;
}

return _CSTD strcmp(_Tptr->raw_name() + 1, _Right._Tptr->raw_name() + 1) <=> 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested, note to final reviewer: This raw_name() + 1 looks like 5 squirrels out of 5 🐿️ but it's exactly the correct technique.

  • __std_type_info_compare() in std_type_info.cpp (internal link) compares strcmp(lhs->_DecoratedName + 1, rhs->_DecoratedName + 1).
  • type_info::raw_name() in vcruntime_typeinfo.h (internal link) says return _Data._DecoratedName;.
  • The character at index 0 appears to be a dot; I'm not sure why that's stored, or why raw_name() exposes this, but the implementation here is correct.

}
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
_NODISCARD bool operator!=(const type_index& _Right) const noexcept {
Expand Down