brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · c89b1ee Raw
50 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 explicit sentinel(split_view& parent);12 13#include <cassert>14#include <ranges>15#include <type_traits>16 17#include "test_iterators.h"18 19// test explicit20using Range     = std::ranges::subrange<int*, sentinel_wrapper<int*>>;21using SplitView = std::ranges::split_view<Range, std::ranges::single_view<int>>;22using SplitSent = std::ranges::sentinel_t<SplitView>;23 24static_assert(std::is_constructible_v<SplitSent, SplitView&>);25static_assert(!std::is_convertible_v<SplitView&, SplitSent>);26 27constexpr bool test() {28  {29    int buffer[] = {0, 1, 2};30    Range input{buffer, sentinel_wrapper<int*>(buffer + 3)};31    SplitView sv(input, -1);32    auto it = sv.begin();33 34    SplitSent sent(sv);35    assert(sent != it);36 37    ++it;38    assert(sent == it);39  }40 41  return true;42}43 44int main(int, char**) {45  test();46  static_assert(test());47 48  return 0;49}50