This is an archive of the discontinued LLVM Phabricator instance.

[libc++][NFC] Remove several redundant #if _LIBCPP_STD_VER > 17 in <span>
ClosedPublic

Authored by ldionne on Mar 14 2022, 8:38 AM.

Details

Summary

It turns out that the whole header is only enabled in C++20 and above,
so these checks were redundant (and always true).

Diff Detail

Event Timeline

ldionne created this revision.Mar 14 2022, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 8:38 AM
ldionne requested review of this revision.Mar 14 2022, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 8:38 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik added inline comments.
libcxx/include/span
255

Why have you removed the comment completely? (Also in line 437)

jloser accepted this revision.Mar 14 2022, 9:28 AM

LGTM - thanks for noticing this! I'd appreciate it if you fix @philnik nits on the macro #endif comments removed before landing this.

ldionne added inline comments.Mar 14 2022, 9:56 AM
libcxx/include/span
255

When blocks are really small, the readability improvement of commenting the #endif is questionable.

Do you agree @jloser @philnik ? If not, I don't mind adding them back.

philnik added inline comments.Mar 14 2022, 10:04 AM
libcxx/include/span
255

I think I'd like to keep them. In some situations it drastically increases readability and definitely doesn't hurt even with these small blocks.

Mordante accepted this revision as: Mordante.Mar 14 2022, 10:22 AM
Mordante added a subscriber: Mordante.

Nice catch LGTM! I've no strong preference regarding the removed comments. For these small blocks I tend to omit them.

jloser added inline comments.Mar 14 2022, 10:42 AM
libcxx/include/span
255

I'm fine omitting them for small blocks. For larger blocks, I like having them.

ldionne marked 3 inline comments as done.Mar 14 2022, 10:50 AM
ldionne added inline comments.
libcxx/include/span
255

I'll re-add it for __span_compatible_range above (I was actually not convinced when I removed it), but the other ones are really small, so removing them is more consistent with the rest of the library. Hopefully that should strike the right balance and everybody should find it reasonable.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 14 2022, 10:53 AM
This revision was automatically updated to reflect the committed changes.
ldionne marked an inline comment as done.