brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 721a1cc Raw
48 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// constexpr value_type operator*() const;12//   Effects: Equivalent to return {cur_, next_.begin()};13 14#include <cassert>15#include <ranges>16 17#include "../types.h"18 19struct Iter : ForwardIterBase<Iter> {20  int i;21  constexpr Iter() = default;22  constexpr Iter(int ii) : i(ii) {}23};24 25constexpr bool test() {26  using SplitView = std::ranges::split_view<std::ranges::subrange<Iter>, std::ranges::subrange<Iter>>;27  using SplitIter = std::ranges::iterator_t<SplitView>;28 29  {30    SplitView sv;31    Iter current{5};32    std::ranges::subrange next{Iter{6}, Iter{7}};33    const SplitIter it{sv, current, next};34    std::same_as<std::ranges::subrange<Iter>> decltype(auto) value = *it;35    assert(value.begin().i == 5);36    assert(value.end().i == 6);37  }38 39  return true;40}41 42int main(int, char**) {43  test();44  static_assert(test());45 46  return 0;47}48