1d8fad661SChristopher Di Bella //===----------------------------------------------------------------------===//
2d8fad661SChristopher Di Bella //
3d8fad661SChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4d8fad661SChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
5d8fad661SChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d8fad661SChristopher Di Bella //
7d8fad661SChristopher Di Bella //===----------------------------------------------------------------------===//
8d8fad661SChristopher Di Bella 
9d8fad661SChristopher Di Bella // UNSUPPORTED: c++03, c++11, c++14, c++17
10*71909de3SMark de Wever // UNSUPPORTED: libcpp-has-no-incomplete-ranges
11d8fad661SChristopher Di Bella 
12d8fad661SChristopher Di Bella // <ranges>
13d8fad661SChristopher Di Bella 
14d8fad661SChristopher Di Bella // template<class T>
15d8fad661SChristopher Di Bella // concept view = ...;
16d8fad661SChristopher Di Bella 
17d8fad661SChristopher Di Bella #include <ranges>
18d8fad661SChristopher Di Bella 
19d8fad661SChristopher Di Bella #include "test_macros.h"
20d8fad661SChristopher Di Bella 
21d8fad661SChristopher Di Bella // The type would be a view, but it's not moveable.
22d8fad661SChristopher Di Bella struct NotMoveable : std::ranges::view_base {
23d8fad661SChristopher Di Bella   NotMoveable() = default;
24d8fad661SChristopher Di Bella   NotMoveable(NotMoveable&&) = delete;
25d8fad661SChristopher Di Bella   NotMoveable& operator=(NotMoveable&&) = delete;
26d8fad661SChristopher Di Bella   friend int* begin(NotMoveable&);
27d8fad661SChristopher Di Bella   friend int* begin(NotMoveable const&);
28d8fad661SChristopher Di Bella   friend int* end(NotMoveable&);
29d8fad661SChristopher Di Bella   friend int* end(NotMoveable const&);
30d8fad661SChristopher Di Bella };
31d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotMoveable>);
32d8fad661SChristopher Di Bella static_assert(!std::movable<NotMoveable>);
33d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotMoveable>);
34d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotMoveable>);
35d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotMoveable>);
36d8fad661SChristopher Di Bella 
37d8fad661SChristopher Di Bella // The type would be a view, but it's not default initializable
38d8fad661SChristopher Di Bella struct NotDefaultInit : std::ranges::view_base {
39d8fad661SChristopher Di Bella   NotDefaultInit() = delete;
40d8fad661SChristopher Di Bella   friend int* begin(NotDefaultInit&);
41d8fad661SChristopher Di Bella   friend int* begin(NotDefaultInit const&);
42d8fad661SChristopher Di Bella   friend int* end(NotDefaultInit&);
43d8fad661SChristopher Di Bella   friend int* end(NotDefaultInit const&);
44d8fad661SChristopher Di Bella };
45d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotDefaultInit>);
46d8fad661SChristopher Di Bella static_assert(std::movable<NotDefaultInit>);
47d8fad661SChristopher Di Bella static_assert(!std::default_initializable<NotDefaultInit>);
48d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotDefaultInit>);
49462f8f06SChristopher Di Bella static_assert(std::ranges::view<NotDefaultInit>);
50d8fad661SChristopher Di Bella 
51d8fad661SChristopher Di Bella // The type would be a view, but it doesn't enable it with enable_view
52d8fad661SChristopher Di Bella struct NotExplicitlyEnabled {
53d8fad661SChristopher Di Bella   NotExplicitlyEnabled() = default;
54d8fad661SChristopher Di Bella   NotExplicitlyEnabled(NotExplicitlyEnabled&&) = default;
55d8fad661SChristopher Di Bella   NotExplicitlyEnabled& operator=(NotExplicitlyEnabled&&) = default;
56d8fad661SChristopher Di Bella   friend int* begin(NotExplicitlyEnabled&);
57d8fad661SChristopher Di Bella   friend int* begin(NotExplicitlyEnabled const&);
58d8fad661SChristopher Di Bella   friend int* end(NotExplicitlyEnabled&);
59d8fad661SChristopher Di Bella   friend int* end(NotExplicitlyEnabled const&);
60d8fad661SChristopher Di Bella };
61d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotExplicitlyEnabled>);
62d8fad661SChristopher Di Bella static_assert(std::movable<NotExplicitlyEnabled>);
63d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotExplicitlyEnabled>);
64d8fad661SChristopher Di Bella static_assert(!std::ranges::enable_view<NotExplicitlyEnabled>);
65d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotExplicitlyEnabled>);
66d8fad661SChristopher Di Bella 
67d8fad661SChristopher Di Bella // The type has everything else, but it's not a range
68d8fad661SChristopher Di Bella struct NotARange : std::ranges::view_base {
69d8fad661SChristopher Di Bella   NotARange() = default;
70d8fad661SChristopher Di Bella   NotARange(NotARange&&) = default;
71d8fad661SChristopher Di Bella   NotARange& operator=(NotARange&&) = default;
72d8fad661SChristopher Di Bella };
73d8fad661SChristopher Di Bella static_assert(!std::ranges::range<NotARange>);
74d8fad661SChristopher Di Bella static_assert(std::movable<NotARange>);
75d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotARange>);
76d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotARange>);
77d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotARange>);
78d8fad661SChristopher Di Bella 
79d8fad661SChristopher Di Bella // The type satisfies all requirements
80d8fad661SChristopher Di Bella struct View : std::ranges::view_base {
81d8fad661SChristopher Di Bella   View() = default;
82d8fad661SChristopher Di Bella   View(View&&) = default;
83d8fad661SChristopher Di Bella   View& operator=(View&&) = default;
84d8fad661SChristopher Di Bella   friend int* begin(View&);
85d8fad661SChristopher Di Bella   friend int* begin(View const&);
86d8fad661SChristopher Di Bella   friend int* end(View&);
87d8fad661SChristopher Di Bella   friend int* end(View const&);
88d8fad661SChristopher Di Bella };
89d8fad661SChristopher Di Bella static_assert(std::ranges::range<View>);
90d8fad661SChristopher Di Bella static_assert(std::movable<View>);
91d8fad661SChristopher Di Bella static_assert(std::default_initializable<View>);
92d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<View>);
93d8fad661SChristopher Di Bella static_assert(std::ranges::view<View>);
94