This is an archive of the discontinued LLVM Phabricator instance.

[libc++][spaceship] Implement `operator<=>` for `optional`
ClosedPublic

Authored by H-G-Hristov on Mar 19 2023, 2:06 PM.

Details

Summary

Implements parts of P1614R2: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html

Diff Detail

Event Timeline

H-G-Hristov created this revision.Mar 19 2023, 2:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2023, 2:06 PM
  • Updated SpaceshipProjects.csv
H-G-Hristov edited the summary of this revision. (Show Details)Mar 21 2023, 12:51 PM
H-G-Hristov edited the summary of this revision. (Show Details)Mar 24 2023, 5:16 AM
H-G-Hristov edited the summary of this revision. (Show Details)Mar 24 2023, 5:41 AM
  • Minor tweak
H-G-Hristov published this revision for review.Apr 1 2023, 3:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2023, 3:13 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik requested changes to this revision.Apr 1 2023, 4:30 AM
philnik added a subscriber: philnik.
philnik added inline comments.
libcxx/docs/Status/SpaceshipProjects.csv
25

It looks like this patch implements LWG3566. If that's the case, please mark it as completed.

libcxx/include/optional
1330

Please clang-format the new code.

1431

This should just be an #else AFAICT.

1588

Please implement LWG3746.

libcxx/test/std/utilities/optional/optional.comp_with_t/compare.three_way.pass.cpp
26

Please add a SFINAE test for the three_way_comparable_with constraint.

29

Please also add tests for a user-defined type that is comparable to int.

libcxx/test/std/utilities/optional/optional.relops/compare.three_way.pass.cpp
27–30

Also, let's use two optionals to make sure it's not comparing addresses or something like that.

31

Please also add tests where one of the optionals has a value (both left and right).

This revision now requires changes to proceed.Apr 1 2023, 4:30 AM
H-G-Hristov edited the summary of this revision. (Show Details)Apr 1 2023, 6:37 AM
H-G-Hristov updated this revision to Diff 510227.EditedApr 1 2023, 7:44 AM
H-G-Hristov marked 8 inline comments as done.

Thank you for the review.

  • Addressed comments
H-G-Hristov planned changes to this revision.Apr 1 2023, 7:48 AM
  • Implemented LWG3746
  • Minor tweaks

Ping @philnik

The CI issue is unrelated.

Sorry if personal pings are unacceptable!

philnik accepted this revision.Apr 27 2023, 12:04 PM

Ping @philnik

The CI issue is unrelated.

Sorry if personal pings are unacceptable!

That's fine (and even important in some cases), especially if the person requested changes.

LGTM with the last comment addressed.

libcxx/test/std/utilities/optional/optional.comp_with_t/compare.three_way.pass.cpp
29

I wanted you to test that it doesn't convert 'U' to 'T' :D (The other tests are also nice though)

35–76

I don't think any of this is necessary. You don't have to make it work like an int to make it comparable to an int.

This revision is now accepted and ready to land.Apr 27 2023, 12:04 PM
  • Addressed comments
H-G-Hristov marked an inline comment as done.Apr 30 2023, 1:39 AM

Thank you for the review. I think I have addressed your comment. I just don't get what's going on with the CI. I haven't seen a green build for over a week.

Thank you for the review. I think I have addressed your comment. I just don't get what's going on with the CI. I haven't seen a green build for over a week.

The santizers are known to be buggy at the moment. The others should work again.

libcxx/include/optional
1431

Typically we use the same condition in the comments. I was confused you wanted to use operator<=> before C++20.

  • Addressed comments
H-G-Hristov marked an inline comment as done.May 3 2023, 12:29 PM

Thank you for the review. I think I have addressed your comment. I just don't get what's going on with the CI. I haven't seen a green build for over a week.

The santizers are known to be buggy at the moment. The others should work again.

@Mordante Thank you for the remark. It looks like I marked the comment as done but failed to do it.

In most of my revisions I see: merge_guards_bot fail and no other info or at least I don't know what to look for.

ldionne accepted this revision.May 4 2023, 1:53 PM
ldionne added a subscriber: ldionne.

LGTM. The CI is passing if you know where to look. Thanks a lot for the patch!

This revision was landed with ongoing or failed builds.May 4 2023, 11:59 PM
This revision was automatically updated to reflect the committed changes.