[libcxx-commits] [PATCH] D118809: [libc++] Define `namespace views` in its own detail header.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 2 09:27:54 PST 2022


Quuxplusone created this revision.
Quuxplusone added reviewers: jloser, ldionne, philnik, var-const, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

Discovered in the comments on D118748 <https://reviews.llvm.org/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.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118809

Files:
  libcxx/include/__ranges/views.h
  libcxx/include/ranges
  libcxx/test/libcxx/diagnostics/detail.headers/ranges/views.module.verify.cpp


Index: libcxx/test/libcxx/diagnostics/detail.headers/ranges/views.module.verify.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/diagnostics/detail.headers/ranges/views.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__ranges/views.h'}}
+#include <__ranges/views.h>
Index: libcxx/include/ranges
===================================================================
--- libcxx/include/ranges
+++ libcxx/include/ranges
@@ -227,6 +227,7 @@
 #include <__ranges/subrange.h>
 #include <__ranges/take_view.h>
 #include <__ranges/transform_view.h>
+#include <__ranges/views.h>
 #include <__ranges/view_interface.h>
 #include <compare>          // Required by the standard.
 #include <initializer_list> // Required by the standard.
@@ -237,16 +238,6 @@
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace views = ranges::views;
-
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-_LIBCPP_END_NAMESPACE_STD
-
 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
 
 #endif // _LIBCPP_RANGES
Index: libcxx/include/__ranges/views.h
===================================================================
--- /dev/null
+++ libcxx/include/__ranges/views.h
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_VIEWS
+#define _LIBCPP___RANGES_VIEWS
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+namespace views { }
+
+} // namespace ranges
+
+namespace views = ranges::views;
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___RANGES_VIEWS
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118809.405307.patch
Type: text/x-patch
Size: 2738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220202/6320e8d4/attachment.bin>


More information about the libcxx-commits mailing list