Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,10 @@ namespace ranges {
&& requires(_Rng& __r) { _RANGES size(__r); };
// clang-format on

// ALIAS TEMPLATE ranges::range_size_t
template <sized_range _Rng>
using range_size_t = decltype(_RANGES size(_STD declval<_Rng&>()));

// STRUCT ranges::view_base
struct view_base {};

Expand Down
5 changes: 5 additions & 0 deletions tests/std/tests/P0896R4_ranges_range_machinery/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ concept CanEmpty = requires(R&& r) { ranges::empty(std::forward<R>(r)); };
template <class R>
concept CanSize = requires(R&& r) { ranges::size(std::forward<R>(r)); };

template <class R>
concept CanSizeType = requires { typename ranges::range_size_t<R>; };

template <class R>
concept CanData = requires(R&& r) { ranges::data(std::forward<R>(r)); };

Expand Down Expand Up @@ -321,9 +324,11 @@ constexpr bool test_size() {
STATIC_ASSERT(!is_valid<Size> || std::integral<Size>);

STATIC_ASSERT(CanSize<Range> == is_valid<Size>);
STATIC_ASSERT(CanSizeType<Range> == is_valid<Size>);
STATIC_ASSERT(ranges::sized_range<Range> == is_valid<Size>);
if constexpr (is_valid<Size>) {
STATIC_ASSERT(std::same_as<decltype(ranges::size(std::declval<Range>())), Size>);
STATIC_ASSERT(std::same_as<ranges::range_size_t<Range>, Size>);

STATIC_ASSERT(CanEmpty<Range>);
}
Expand Down