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 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
12
13 // constexpr T* end() noexcept;
14 // constexpr const T* end() const noexcept;
15
16 #include <ranges>
17 #include <cassert>
18
19 #include "test_macros.h"
20
21 struct Empty {};
22 struct BigType { char buffer[64] = {10}; };
23
test()24 constexpr bool test() {
25 {
26 auto sv = std::ranges::single_view<int>(42);
27 assert(sv.end() == sv.begin() + 1);
28
29 ASSERT_SAME_TYPE(decltype(sv.end()), int*);
30 static_assert(noexcept(sv.end()));
31 }
32 {
33 const auto sv = std::ranges::single_view<int>(42);
34 assert(sv.end() == sv.begin() + 1);
35
36 ASSERT_SAME_TYPE(decltype(sv.end()), const int*);
37 static_assert(noexcept(sv.end()));
38 }
39
40 {
41 auto sv = std::ranges::single_view<Empty>(Empty());
42 assert(sv.end() == sv.begin() + 1);
43
44 ASSERT_SAME_TYPE(decltype(sv.end()), Empty*);
45 }
46 {
47 const auto sv = std::ranges::single_view<Empty>(Empty());
48 assert(sv.end() == sv.begin() + 1);
49
50 ASSERT_SAME_TYPE(decltype(sv.end()), const Empty*);
51 }
52
53 {
54 auto sv = std::ranges::single_view<BigType>(BigType());
55 assert(sv.end() == sv.begin() + 1);
56
57 ASSERT_SAME_TYPE(decltype(sv.end()), BigType*);
58 }
59 {
60 const auto sv = std::ranges::single_view<BigType>(BigType());
61 assert(sv.end() == sv.begin() + 1);
62
63 ASSERT_SAME_TYPE(decltype(sv.end()), const BigType*);
64 }
65
66 return true;
67 }
68
main(int,char **)69 int main(int, char**) {
70 test();
71 static_assert(test());
72
73 return 0;
74 }
75