summaryrefslogtreecommitdiff
path: root/libcxx/test/std/ranges/range.adaptors/range.split/iterator/deref.pass.cpp
blob: 721a1cc0da3d495c46617b6fe8e66f8783065d78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17

// constexpr value_type operator*() const;
//   Effects: Equivalent to return {cur_, next_.begin()};

#include <cassert>
#include <ranges>

#include "../types.h"

struct Iter : ForwardIterBase<Iter> {
  int i;
  constexpr Iter() = default;
  constexpr Iter(int ii) : i(ii) {}
};

constexpr bool test() {
  using SplitView = std::ranges::split_view<std::ranges::subrange<Iter>, std::ranges::subrange<Iter>>;
  using SplitIter = std::ranges::iterator_t<SplitView>;

  {
    SplitView sv;
    Iter current{5};
    std::ranges::subrange next{Iter{6}, Iter{7}};
    const SplitIter it{sv, current, next};
    std::same_as<std::ranges::subrange<Iter>> decltype(auto) value = *it;
    assert(value.begin().i == 5);
    assert(value.end().i == 6);
  }

  return true;
}

int main(int, char**) {
  test();
  static_assert(test());

  return 0;
}