Skip to content

Commit

Permalink
[libcxx][ranges] Move namespace views into namespace ranges and a…
Browse files Browse the repository at this point in the history
…dd an alias.

Differential Revision: https://reviews.llvm.org/D108047
  • Loading branch information
zoecarver committed Aug 13, 2021
1 parent 1f7b25e commit 9ed0778
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libcxx/include/__ranges/all.h
Expand Up @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if !defined(_LIBCPP_HAS_NO_RANGES)

namespace views {
namespace ranges::views {

namespace __all {
struct __fn {
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__ranges/counted.h
Expand Up @@ -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>
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__ranges/iota_view.h
Expand Up @@ -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 {
Expand Down Expand Up @@ -395,6 +394,7 @@ inline namespace __cpo {
inline constexpr auto iota = __iota::__fn{};
}
} // namespace views
} // namespace ranges

#endif // !defined(_LIBCPP_HAS_NO_RANGES)

Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/ranges
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions libcxx/test/std/ranges/range.adaptors/range.all/all.pass.cpp
Expand Up @@ -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;
}

Expand Down
Expand Up @@ -195,6 +195,10 @@ constexpr bool test() {
}
}

{
static_assert(std::same_as<decltype(std::views::counted), decltype(std::ranges::views::counted)>);
}

return true;
}

Expand Down
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9ed0778

Please sign in to comment.