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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// constexpr explicit sentinel(Bound bound);
12
13#include <cassert>
14#include <ranges>
15#include <type_traits>
16
17#include "test_macros.h"
18#include "../types.h"
19
20constexpr bool test() {
21 {
22 using Sent = std::ranges::sentinel_t<std::ranges::iota_view<int, IntSentinelWith<int>>>;
23 using Iter = std::ranges::iterator_t<std::ranges::iota_view<int, IntSentinelWith<int>>>;
24 auto sent = Sent(IntSentinelWith<int>(42));
25 assert(sent == Iter(42));
26 }
27 {
28 using Sent = std::ranges::sentinel_t<std::ranges::iota_view<SomeInt, IntSentinelWith<SomeInt>>>;
29 using Iter = std::ranges::iterator_t<std::ranges::iota_view<SomeInt, IntSentinelWith<SomeInt>>>;
30 auto sent = Sent(IntSentinelWith<SomeInt>(SomeInt(42)));
31 assert(sent == Iter(SomeInt(42)));
32 }
33 {
34 using Sent = std::ranges::sentinel_t<std::ranges::iota_view<SomeInt, IntSentinelWith<SomeInt>>>;
35 static_assert(!std::is_convertible_v<Sent, IntSentinelWith<SomeInt>>);
36 static_assert( std::is_constructible_v<Sent, IntSentinelWith<SomeInt>>);
37 }
38
39 return true;
40}
41
42int main(int, char**) {
43 test();
44 static_assert(test());
45
46 return 0;
47}
48

source code of libcxx/test/std/ranges/range.factories/range.iota.view/sentinel/ctor.value.pass.cpp