brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 1ac6827 Raw
44 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(Parent& parent);12 13#include <cassert>14#include <ranges>15 16#include "test_macros.h"17#include "../types.h"18 19constexpr bool test() {20  int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};21 22  CopyableChild children[4] = {CopyableChild(buffer[0]), CopyableChild(buffer[1]), CopyableChild(buffer[2]), CopyableChild(buffer[3])};23  CopyableParent parent{children};24  std::ranges::join_view jv(parent);25  std::ranges::sentinel_t<decltype(jv)> sent(jv);26  assert(sent == std::ranges::next(jv.begin(), 16));27 28  return true;29}30 31int main(int, char**) {32  test();33  static_assert(test());34 35  {36    // Test explicitness.37    using Parent = std::ranges::join_view<ParentView<ChildView>>;38    static_assert( std::is_constructible_v<std::ranges::sentinel_t<Parent>, Parent&>);39    static_assert(!std::is_convertible_v<std::ranges::sentinel_t<Parent>, Parent&>);40  }41 42  return 0;43}44