[libcxx-commits] [libcxx] 9ed0778 - [libcxx][ranges] Move `namespace views` into `namespace ranges` and add an alias.
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 13 16:12:29 PDT 2021
Author: zoecarver
Date: 2021-08-13T16:12:19-07:00
New Revision: 9ed07781791054f9e129c892adf819b55d6e6c44
URL: https://github.com/llvm/llvm-project/commit/9ed07781791054f9e129c892adf819b55d6e6c44
DIFF: https://github.com/llvm/llvm-project/commit/9ed07781791054f9e129c892adf819b55d6e6c44.diff
LOG: [libcxx][ranges] Move `namespace views` into `namespace ranges` and add an alias.
Differential Revision: https://reviews.llvm.org/D108047
Added:
Modified:
libcxx/include/__ranges/all.h
libcxx/include/__ranges/counted.h
libcxx/include/__ranges/iota_view.h
libcxx/include/ranges
libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp
libcxx/test/std/ranges/range.adaptors/range.counted/counted.pass.cpp
libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__ranges/all.h b/libcxx/include/__ranges/all.h
index d678d3e5d357c..f44beaa272722 100644
--- a/libcxx/include/__ranges/all.h
+++ b/libcxx/include/__ranges/all.h
@@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RANGES)
-namespace views {
+namespace ranges::views {
namespace __all {
struct __fn {
@@ -75,7 +75,7 @@ inline namespace __cpo {
template<ranges::viewable_range _Range>
using all_t = decltype(views::all(declval<_Range>()));
-} // namespace views
+} // namespace ranges::views
#endif // !defined(_LIBCPP_HAS_NO_RANGES)
diff --git a/libcxx/include/__ranges/counted.h b/libcxx/include/__ranges/counted.h
index d891c1f4efac4..d7240803608f7 100644
--- a/libcxx/include/__ranges/counted.h
+++ b/libcxx/include/__ranges/counted.h
@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RANGES)
-namespace views {
+namespace ranges::views {
namespace __counted {
template<class _From, class _To>
@@ -88,7 +88,7 @@ inline namespace __cpo {
inline constexpr auto counted = __counted::__fn{};
} // namespace __cpo
-} // namespace views
+} // namespace ranges::views
#endif // !defined(_LIBCPP_HAS_NO_RANGES)
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index f302826b02474..047d8460c268b 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -366,7 +366,6 @@ namespace ranges {
template<class _Start, class _Bound>
inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;
-} // namespace ranges
namespace views {
namespace __iota {
@@ -395,6 +394,7 @@ inline namespace __cpo {
inline constexpr auto iota = __iota::__fn{};
}
} // namespace views
+} // namespace ranges
#endif // !defined(_LIBCPP_HAS_NO_RANGES)
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index 014260aaee15b..a4cbfafd5f99e 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -238,6 +238,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+namespace views = ranges::views;
+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp
index 2aeb94f8bd4cb..cef873465eb65 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp
@@ -142,6 +142,10 @@ constexpr bool test() {
assert(std::ranges::end(subrange) == std::ranges::begin(subrange) + 8);
}
+ {
+ static_assert(std::same_as<decltype(std::views::all), decltype(std::ranges::views::all)>);
+ }
+
return true;
}
diff --git a/libcxx/test/std/ranges/range.adaptors/range.counted/counted.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.counted/counted.pass.cpp
index 62791bbdd28a0..2ebd7036db33a 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.counted/counted.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.counted/counted.pass.cpp
@@ -195,6 +195,10 @@ constexpr bool test() {
}
}
+ {
+ static_assert(std::same_as<decltype(std::views::counted), decltype(std::ranges::views::counted)>);
+ }
+
return true;
}
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.pass.cpp
index 661285585095c..6fcb4abe21dec 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.pass.cpp
@@ -71,6 +71,9 @@ constexpr bool test() {
static_assert( std::is_invocable_v<decltype(std::views::iota), int, int>);
static_assert(!std::is_invocable_v<decltype(std::views::iota), int, X>);
}
+ {
+ static_assert(std::same_as<decltype(std::views::iota), decltype(std::ranges::views::iota)>);
+ }
return true;
}
More information about the libcxx-commits
mailing list