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 10d8fad661SChristopher Di Bella // UNSUPPORTED: libcpp-no-concepts 11*71909de3SMark de Wever // UNSUPPORTED: libcpp-has-no-incomplete-ranges 12d8fad661SChristopher Di Bella 13d8fad661SChristopher Di Bella // <ranges> 14d8fad661SChristopher Di Bella 15d8fad661SChristopher Di Bella // template<class T> 16d8fad661SChristopher Di Bella // concept view = ...; 17d8fad661SChristopher Di Bella 18d8fad661SChristopher Di Bella #include <ranges> 19d8fad661SChristopher Di Bella 20d8fad661SChristopher Di Bella #include "test_macros.h" 21d8fad661SChristopher Di Bella 22d8fad661SChristopher Di Bella // The type would be a view, but it's not moveable. 23d8fad661SChristopher Di Bella struct NotMoveable : std::ranges::view_base { 24d8fad661SChristopher Di Bella NotMoveable() = default; 25d8fad661SChristopher Di Bella NotMoveable(NotMoveable&&) = delete; 26d8fad661SChristopher Di Bella NotMoveable& operator=(NotMoveable&&) = delete; 27d8fad661SChristopher Di Bella friend int* begin(NotMoveable&); 28d8fad661SChristopher Di Bella friend int* begin(NotMoveable const&); 29d8fad661SChristopher Di Bella friend int* end(NotMoveable&); 30d8fad661SChristopher Di Bella friend int* end(NotMoveable const&); 31d8fad661SChristopher Di Bella }; 32d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotMoveable>); 33d8fad661SChristopher Di Bella static_assert(!std::movable<NotMoveable>); 34d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotMoveable>); 35d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotMoveable>); 36d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotMoveable>); 37d8fad661SChristopher Di Bella 38d8fad661SChristopher Di Bella // The type would be a view, but it's not default initializable 39d8fad661SChristopher Di Bella struct NotDefaultInit : std::ranges::view_base { 40d8fad661SChristopher Di Bella NotDefaultInit() = delete; 41d8fad661SChristopher Di Bella friend int* begin(NotDefaultInit&); 42d8fad661SChristopher Di Bella friend int* begin(NotDefaultInit const&); 43d8fad661SChristopher Di Bella friend int* end(NotDefaultInit&); 44d8fad661SChristopher Di Bella friend int* end(NotDefaultInit const&); 45d8fad661SChristopher Di Bella }; 46d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotDefaultInit>); 47d8fad661SChristopher Di Bella static_assert(std::movable<NotDefaultInit>); 48d8fad661SChristopher Di Bella static_assert(!std::default_initializable<NotDefaultInit>); 49d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotDefaultInit>); 50462f8f06SChristopher Di Bella static_assert(std::ranges::view<NotDefaultInit>); 51d8fad661SChristopher Di Bella 52d8fad661SChristopher Di Bella // The type would be a view, but it doesn't enable it with enable_view 53d8fad661SChristopher Di Bella struct NotExplicitlyEnabled { 54d8fad661SChristopher Di Bella NotExplicitlyEnabled() = default; 55d8fad661SChristopher Di Bella NotExplicitlyEnabled(NotExplicitlyEnabled&&) = default; 56d8fad661SChristopher Di Bella NotExplicitlyEnabled& operator=(NotExplicitlyEnabled&&) = default; 57d8fad661SChristopher Di Bella friend int* begin(NotExplicitlyEnabled&); 58d8fad661SChristopher Di Bella friend int* begin(NotExplicitlyEnabled const&); 59d8fad661SChristopher Di Bella friend int* end(NotExplicitlyEnabled&); 60d8fad661SChristopher Di Bella friend int* end(NotExplicitlyEnabled const&); 61d8fad661SChristopher Di Bella }; 62d8fad661SChristopher Di Bella static_assert(std::ranges::range<NotExplicitlyEnabled>); 63d8fad661SChristopher Di Bella static_assert(std::movable<NotExplicitlyEnabled>); 64d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotExplicitlyEnabled>); 65d8fad661SChristopher Di Bella static_assert(!std::ranges::enable_view<NotExplicitlyEnabled>); 66d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotExplicitlyEnabled>); 67d8fad661SChristopher Di Bella 68d8fad661SChristopher Di Bella // The type has everything else, but it's not a range 69d8fad661SChristopher Di Bella struct NotARange : std::ranges::view_base { 70d8fad661SChristopher Di Bella NotARange() = default; 71d8fad661SChristopher Di Bella NotARange(NotARange&&) = default; 72d8fad661SChristopher Di Bella NotARange& operator=(NotARange&&) = default; 73d8fad661SChristopher Di Bella }; 74d8fad661SChristopher Di Bella static_assert(!std::ranges::range<NotARange>); 75d8fad661SChristopher Di Bella static_assert(std::movable<NotARange>); 76d8fad661SChristopher Di Bella static_assert(std::default_initializable<NotARange>); 77d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<NotARange>); 78d8fad661SChristopher Di Bella static_assert(!std::ranges::view<NotARange>); 79d8fad661SChristopher Di Bella 80d8fad661SChristopher Di Bella // The type satisfies all requirements 81d8fad661SChristopher Di Bella struct View : std::ranges::view_base { 82d8fad661SChristopher Di Bella View() = default; 83d8fad661SChristopher Di Bella View(View&&) = default; 84d8fad661SChristopher Di Bella View& operator=(View&&) = default; 85d8fad661SChristopher Di Bella friend int* begin(View&); 86d8fad661SChristopher Di Bella friend int* begin(View const&); 87d8fad661SChristopher Di Bella friend int* end(View&); 88d8fad661SChristopher Di Bella friend int* end(View const&); 89d8fad661SChristopher Di Bella }; 90d8fad661SChristopher Di Bella static_assert(std::ranges::range<View>); 91d8fad661SChristopher Di Bella static_assert(std::movable<View>); 92d8fad661SChristopher Di Bella static_assert(std::default_initializable<View>); 93d8fad661SChristopher Di Bella static_assert(std::ranges::enable_view<View>); 94d8fad661SChristopher Di Bella static_assert(std::ranges::view<View>); 95