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-has-no-incomplete-ranges 11 12 // Test that iota_view conforms to range and view concepts. 13 14 #include <ranges> 15 16 #include "types.h" 17 18 struct Decrementable { 19 using difference_type = int; 20 21 auto operator<=>(const Decrementable&) const = default; 22 23 Decrementable& operator++(); 24 Decrementable operator++(int); 25 Decrementable& operator--(); 26 Decrementable operator--(int); 27 }; 28 29 struct Incrementable { 30 using difference_type = int; 31 32 auto operator<=>(const Incrementable&) const = default; 33 34 Incrementable& operator++(); 35 Incrementable operator++(int); 36 }; 37 38 static_assert(std::ranges::random_access_range<std::ranges::iota_view<int>>); 39 static_assert(std::ranges::random_access_range<const std::ranges::iota_view<int>>); 40 static_assert(std::ranges::bidirectional_range<std::ranges::iota_view<Decrementable>>); 41 static_assert(std::ranges::forward_range<std::ranges::iota_view<Incrementable>>); 42 static_assert(std::ranges::input_range<std::ranges::iota_view<NotIncrementable>>); 43 static_assert(std::ranges::view<std::ranges::iota_view<int>>); 44