Skip to content

Commit d63d9d1

Browse files
committed
fixup! WIP: [libc++][ranges] Implement ranges::stride_view.
Begin cleanup of end tests. Signed-off-by: Will Hawkins <[email protected]>
1 parent cdb52b4 commit d63d9d1

File tree

1 file changed

+21
-6
lines changed
  • libcxx/test/std/ranges/range.adaptors/range.stride.view

1 file changed

+21
-6
lines changed

libcxx/test/std/ranges/range.adaptors/range.stride.view/end.pass.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <ranges>
1818

19+
#include "test_iterators.h"
1920
#include "types.h"
2021

2122
template <class T>
@@ -35,21 +36,34 @@ template <class T>
3536
concept HasOnlyConstEnd = HasConstEnd<T> && !HasConstAndNonConstEnd<T>;
3637

3738
static_assert(HasOnlyNonConstEnd<std::ranges::stride_view<UnSimpleNoConstCommonView>>);
38-
static_assert(HasOnlyConstEnd<std::ranges::stride_view<BasicTestView<int*, int*>>>);
39+
static_assert(HasOnlyConstEnd<std::ranges::stride_view<SimpleCommonConstView>>);
3940
static_assert(HasConstAndNonConstEnd<std::ranges::stride_view<UnSimpleConstView>>);
4041

41-
static_assert(simple_view<SimpleUnCommonConstView>);
42-
static_assert(!std::ranges::common_range<SimpleUnCommonConstView>);
43-
4442
constexpr bool test_non_default_sentinel() {
4543
{
44+
const int data[3] = {1, 2, 3};
4645
static_assert(simple_view<BasicTestView<int*, int*>>);
4746
static_assert(std::ranges::common_range<BasicTestView<int*, int*>>);
4847
static_assert(std::ranges::sized_range<BasicTestView<int*, int*>>);
4948
static_assert(std::ranges::forward_range<BasicTestView<int*, int*>>);
5049

51-
auto v = BasicTestView<int*, int*>{nullptr, nullptr};
52-
auto sv = std::ranges::stride_view<BasicTestView<int*, int*>>(v, 1);
50+
// A const, simple, common-, sized- and forward-range
51+
auto v = BasicTestView<const int*, const int*>{data, data + 3};
52+
auto sv = std::ranges::stride_view<BasicTestView<const int*, const int*>>(v, 1);
53+
static_assert(!std::is_same_v<std::default_sentinel_t, decltype(sv.end())>);
54+
}
55+
56+
{
57+
int data[3] = {1, 2, 3};
58+
// TODO: start here.
59+
using x = BasicTestView<forward_iterator<int*>, forward_iterator<int*>, false>;
60+
static_assert(simple_view<BasicTestView<forward_iterator<int*>>>);
61+
static_assert(std::ranges::common_range<x>);
62+
static_assert(!std::ranges::sized_range<x>);
63+
static_assert(!std::ranges::bidirectional_range<x>);
64+
65+
auto v = x{forward_iterator(data), forward_iterator(data + 3)};
66+
auto sv = std::ranges::stride_view<x>(v, 1);
5367
static_assert(!std::is_same_v<std::default_sentinel_t, decltype(sv.end())>);
5468
}
5569

@@ -59,6 +73,7 @@ constexpr bool test_non_default_sentinel() {
5973
static_assert(std::ranges::sized_range<UnSimpleNoConstCommonView>);
6074
static_assert(std::ranges::forward_range<UnSimpleNoConstCommonView>);
6175

76+
// An unconst, unsimple, common-, sized- and forward-range
6277
auto v = UnSimpleNoConstCommonView{};
6378
auto sv = std::ranges::stride_view<UnSimpleNoConstCommonView>(v, 1);
6479
static_assert(!std::is_same_v<std::default_sentinel_t, decltype(sv.end())>);

0 commit comments

Comments
 (0)