This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove `operator!=` from `type_info` in C++20
ClosedPublic

Authored by avogelsgesang on Jul 31 2022, 12:55 PM.

Details

Summary

Implements part of:

  • P1614R2 The Mothership has Landed

Diff Detail

Event Timeline

avogelsgesang created this revision.Jul 31 2022, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2022, 12:55 PM
Herald added a subscriber: smeenai. · View Herald Transcript
avogelsgesang requested review of this revision.Jul 31 2022, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2022, 12:55 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Note that there are many more classes for which P1614R2 ("The mothership has landed") just removed the operator!= (typeinfo, allocator, memory_resource, polymorphic_allocator, bitset, scoped_allocator_adaptor,function, unordered_map, unordered_set, move_sentinel, common_iterator, unreachable_sentinel_t, ...).

If you prefer, I could go over all of them in a single commit. Afaict, no test cases need changing, as the operator!= will be synthesized by the compiler and all test cases should still pass unchanged.

Thanks for working on this!

Note that there are many more classes for which P1614R2 ("The mothership has landed") just removed the operator!= (typeinfo, allocator, memory_resource, polymorphic_allocator, bitset, scoped_allocator_adaptor,function, unordered_map, unordered_set, move_sentinel, common_iterator, unreachable_sentinel_t, ...).

If you prefer, I could go over all of them in a single commit. Afaict, no test cases need changing, as the operator!= will be synthesized by the compiler and all test cases should still pass unchanged.

I think it makes sense to do typeinfo separately since that feels a more "sensetive" class.
We haven't fully implemented to polymorphic_allocator allocators yet so they are in the experimental directory. I prefer to do them separately too.

Feel free to do the others in one go. Can you also remove them from chrono? I haven't started on them yet.

libcxx/include/typeinfo
25

Can you also update the Status page? Just add it to the page and mark it directly as complete.

343

This one should be updated too.

Thanks for working on this!

Note that there are many more classes for which P1614R2 ("The mothership has landed") just removed the operator!= (typeinfo, allocator, memory_resource, polymorphic_allocator, bitset, scoped_allocator_adaptor,function, unordered_map, unordered_set, move_sentinel, common_iterator, unreachable_sentinel_t, ...).

If you prefer, I could go over all of them in a single commit. Afaict, no test cases need changing, as the operator!= will be synthesized by the compiler and all test cases should still pass unchanged.

I think it makes sense to do typeinfo separately since that feels a more "sensetive" class.
We haven't fully implemented to polymorphic_allocator allocators yet so they are in the experimental directory. I prefer to do them separately too.

Feel free to do the others in one go. Can you also remove them from chrono? I haven't started on them yet.

I'd actually argue that memory_resource and polymorphic_allocator shouldn't be touched, since they are from LFTSv2 and there the operator!= exists.

I'd actually argue that memory_resource and polymorphic_allocator shouldn't be touched, since they are from LFTSv2 and there the operator!= exists.

I'm fine with that too, maybe then a separate commit to only add these changes to the status page, when they aren't there yet. That way we don't accidentally forget about them when porting this code to the main library.

avogelsgesang marked an inline comment as done.

add to status page & remove both operator!= implementations

I'm fine with that too, maybe then a separate commit to only add these changes to the status page, when they aren't there yet. That way we don't accidentally forget about them when porting this code to the main library.

sounds good. I will do so, probably next week

libcxx/include/typeinfo
343

Thanks for catching this! Somehow I assumed there would be only one typeinfo implementation and stopped my search too early...

Is having multiple implementations of the same class a common pattern in libcxx? I know there is a similar pattern for exception_ptr. Anything else which is similar (so I am aware of it while updating other classes)?

Mordante accepted this revision.Aug 4 2022, 9:15 AM

LGTM modulo one small nit.

libcxx/docs/Status/SpaceshipProjects.csv
15
libcxx/include/typeinfo
343

It's very uncommon. Some classes are very closely tied to the platform they execute on. Most of the platform dependent headers are in the __support directory. You just managed to start with a special case for operator!= ;-)

This revision is now accepted and ready to land.Aug 4 2022, 9:15 AM
avogelsgesang marked an inline comment as done.Aug 4 2022, 9:34 AM
This revision was automatically updated to reflect the committed changes.