This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Define `namespace views` in its own detail header.
ClosedPublic

Authored by Quuxplusone on Feb 2 2022, 9:27 AM.

Details

Summary

Discovered in the comments on D118748: we would like this namespace to exist anytime Ranges exists, regardless of whether concepts syntax is supported. Also, we'd like to fully granularize the <ranges> header, which means not putting any loose declarations at the top level.

(Essentially NFC.)

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Feb 2 2022, 9:27 AM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptFeb 2 2022, 9:27 AM

Update cmakelists and modulemap.

Arglebargle. Close namespace std after opening it.

ldionne accepted this revision.Feb 2 2022, 2:23 PM

LGTM, but I think we can pick a better name for the header.

libcxx/include/CMakeLists.txt
354

views_namespace.h or namespace_views.h? Just views.h makes it look like it is an umbrella header for including all views at once.

This revision is now accepted and ready to land.Feb 2 2022, 2:23 PM
Quuxplusone added inline comments.Feb 2 2022, 2:48 PM
libcxx/include/CMakeLists.txt
354

__ranges/namespace_views.h wouldn't be the end of the world, but it would be oddly inconsistent with the usual convention of naming the header after the library name it defines. The header that defines the-thing-named-views should be named views.h, IMO.
(This is our convention with the notable exception of __ranges/access.h, which I've tried to disentangle before and found it's sadly really difficult.)

ldionne added inline comments.Feb 3 2022, 1:54 PM
libcxx/include/CMakeLists.txt
354

Okay, I'm neutral then. Go by your preference.

jloser accepted this revision.Feb 3 2022, 6:22 PM

#include <__config> (I should add a linter test for this line as well!)
If CI is green, imma land this.

dim added a subscriber: dim.Apr 7 2022, 12:33 PM

It's a pity this one didn't make it into 14.0.0, as you now can't even include <ranges> without immediately getting an error:

% cat test-ranges.cpp
#include <ranges>

% c++ -c test-ranges.cpp
In file included from test-ranges.cpp:1:
/usr/include/c++/v1/ranges:240:19: error: use of undeclared identifier 'ranges'
namespace views = ranges::views;
                  ^
1 error generated.

This should definitely go into 14.0.1, then?

Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 12:33 PM

It's a pity this one didn't make it into 14.0.0, as you now can't even include <ranges> without immediately getting an error:

% cat test-ranges.cpp
#include <ranges>

% c++ -c test-ranges.cpp
In file included from test-ranges.cpp:1:
/usr/include/c++/v1/ranges:240:19: error: use of undeclared identifier 'ranges'
namespace views = ranges::views;
                  ^
1 error generated.

This should definitely go into 14.0.1, then?

Sorry, this missed 14.0.1 too, but I just cherry-picked it to the release/14.x branch:

[libc++] Define `namespace views` in its own detail header.

Discovered in the comments on D118748: we would like this namespace
to exist anytime Ranges exists, regardless of whether concepts syntax
is supported. Also, we'd like to fully granularize the <ranges> header,
which means not putting any loose declarations at the top level.

Differential Revision: https://reviews.llvm.org/D118809

(cherry picked from commit 44cdca37c01a58da94087be8ebd0ee2bd2ba724e)