This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] adds concept std::regular
ClosedPublic

Authored by cjdb on Mar 7 2021, 1:30 PM.

Details

Summary

Implements parts of:

  • P0898R3 Standard Library Concepts
  • P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97911

Diff Detail

Event Timeline

cjdb requested review of this revision.Mar 7 2021, 1:30 PM
cjdb created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2021, 1:30 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone added inline comments.Mar 7 2021, 5:15 PM
libcxx/test/std/concepts/object/regular.compile.pass.cpp
13

s/From/T/

38

Here I think it would be more interesting to check some other built-in types — notably float/double, void*, and maybe even member-pointer-into-a-union-type (which supports operator== but with underspecified semantics).

You could pay for these new test cases by collapsing the 4 int*/int const*/int volatile*/int volatile const* lines into 1 line, and the following 25 lines into 1 line.

76

This line is out of place.
It did strike me tonight that we could have organized these tests completely differently: we could have presented one type at a time, and static-asserted exactly where it falls on the concept hierarchy. For example:

struct Simple {};
static_assert(std::semiregular<Simple> && !std::regular<Simple>);

struct MoveCtor { MoveCtor(MoveCtor&&); };
static_assert(std::move_constructible<MoveCtor> && !std::movable<MoveCtor>);

and so on.

Mordante added inline comments.Mar 10 2021, 11:00 AM
libcxx/test/std/concepts/object/regular.compile.pass.cpp
76

Isn't this done to show the type is semiregular, but not regular? There are more of these "double tests". But I agree combining them might be better.

121

Could these two also be combined?

EricWF accepted this revision.Mar 11 2021, 11:02 AM

LGTM. I like Arthurs suggestion about the tests. But otherwise this change seems ready to go.

This revision is now accepted and ready to land.Mar 11 2021, 11:02 AM
cjdb updated this revision to Diff 330167.Mar 12 2021, 12:13 AM
cjdb marked 5 inline comments as done.

applies @Quuxplusone's feedback

Quuxplusone accepted this revision.Mar 12 2021, 6:43 AM
Quuxplusone added inline comments.
libcxx/test/std/concepts/object/regular.compile.pass.cpp
145

/lz/liz/

148

/> >/>>/ since this test doesn't need C++03 portability

160

Should this say /On/No/?

This revision was automatically updated to reflect the committed changes.
cjdb marked 2 inline comments as done.
cjdb added a comment.Mar 12 2021, 8:55 AM

@Quuxplusone please check 8d4af1b.

libcxx/test/std/concepts/object/regular.compile.pass.cpp
148

clang-format issue, not arguing over this.

160

Both are semantically correct! I meant this as "on some topic of concern", but I think "no equality comparability" reads better here.