This is an archive of the discontinued LLVM Phabricator instance.

[libc++][docs] Mark LWG3274 as complete
ClosedPublic

Authored by jloser on Oct 10 2021, 5:26 PM.

Details

Summary

Mark LWG3274 as complete. The feature test macro __cpp_lib_span was added in
6d2599e4f776d0cd88438cb82a00c4fc25cc3f67.

https://wg21.link/p1024 mentions marking span:::empty() with
[[nodiscard]] which is not done yet. So, do that and add tests.

Diff Detail

Event Timeline

jloser requested review of this revision.Oct 10 2021, 5:26 PM
jloser created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2021, 5:26 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone requested changes to this revision.Oct 10 2021, 5:52 PM
Quuxplusone added inline comments.
libcxx/docs/Status/Cxx20Issues.csv
186

The feature test macro has indeed been there since forever; but before we mark this "Complete", let's do a pass over the paper that added it
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1024r3.pdf
and see what else might be missing.

I think adding [[nodiscard]] to empty() — and writing a test for that — is all that's needed, then.

This revision now requires changes to proceed.Oct 10 2021, 5:52 PM
jloser updated this revision to Diff 378666.Oct 11 2021, 8:00 AM
jloser edited the summary of this revision. (Show Details)

Mark span::empty as [[nodiscard]] and add tests.

Two small nits, but I'd like to see the CI passing before approving.

libcxx/include/span
333–335

Since the block was manually aligned it would be nice to keep it that way.

libcxx/test/std/containers/views/span.obs/empty.nodiscard.verify.cpp
19

Minor nit can you remove the // and the extra blank line?

jloser added inline comments.Oct 11 2021, 9:23 AM
libcxx/include/span
333–335

With adding [[nodiscard]] it won't be aligned with size() and size_bytes() member function. So, we can either manually align those, or not align empty() member function. I chose the latter. WDYT?

libcxx/test/std/containers/views/span.obs/empty.nodiscard.verify.cpp
19

Sure, but it's consistent with empty.pass where this was copied from for example. Several other tests have this same pattern.

jloser updated this revision to Diff 378713.Oct 11 2021, 10:00 AM

[NFC] Remove extra blank line in empty.nodiscard.verify.cpp

jloser marked an inline comment as done.EditedOct 11 2021, 10:00 AM

Two small nits, but I'd like to see the CI passing before approving.

I think CI is failing due to the unexpectedly pass test due to the copied XFAIL from empty.pass.cpp. Just removed the XFAIL.

jloser updated this revision to Diff 378714.Oct 11 2021, 10:02 AM

Remove XFAIL from test

libcxx/include/span
333–335

Yeah, I think @Mordante was asking for

_LIBCPP_INLINE_VISIBILITY constexpr size_type size()           const noexcept { return _Extent; }
_LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes()     const noexcept { return _Extent * sizeof(element_type); }
[[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }

FWIW, I think it's fine either way, and would err on the side of the smaller diff (as you did) myself, but I don't care.

Mordante added inline comments.Oct 11 2021, 10:28 AM
libcxx/include/span
333–335

Yes that was indeed what I was asking for. It's just a bit odd; on one hand we spend time to make code looking nicely in the original commit, but one the other hand we want to keep our diffs minimal. But it was a suggestion so no blocker.

jloser updated this revision to Diff 378745.Oct 11 2021, 11:38 AM

[NFC] Align member functions near empty() in span

jloser marked 2 inline comments as done.Oct 11 2021, 11:39 AM
jloser added inline comments.
libcxx/include/span
333–335

I just aligned the neighboring member functions. I don't feel strongly either way. Like Arthur said, I like to keep the diff as small as possible, but I hear your argument around making the code look nice.

In any case, CI passed earlier before the whitespace alignment (https://buildkite.com/llvm-project/libcxx-ci/builds/5884). I'll land this later tonight.

jloser marked 3 inline comments as done.Oct 11 2021, 11:40 AM
ldionne accepted this revision.Oct 12 2021, 8:00 AM
This revision is now accepted and ready to land.Oct 12 2021, 8:00 AM
Mordante accepted this revision.Oct 12 2021, 8:29 AM

LGTM!

This revision was automatically updated to reflect the committed changes.