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: gcc-10
12 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
13 
14 // template<class R>
15 // concept forward_range;
16 
17 #include <ranges>
18 
19 #include "test_iterators.h"
20 #include "test_range.h"
21 
22 namespace stdr = std::ranges;
23 
24 template <template <class...> class I>
25 constexpr bool check_forward_range() {
26   constexpr bool result = stdr::forward_range<test_range<I> >;
27   static_assert(stdr::forward_range<test_range<I> const> == result);
28   static_assert(stdr::forward_range<test_non_const_common_range<I> > == result);
29   static_assert(stdr::forward_range<test_non_const_range<I> > == result);
30   static_assert(stdr::forward_range<test_common_range<I> > == result);
31   static_assert(stdr::forward_range<test_common_range<I> const> == result);
32   static_assert(!stdr::forward_range<test_non_const_common_range<I> const>);
33   static_assert(!stdr::forward_range<test_non_const_range<I> const>);
34   return result;
35 }
36 
37 static_assert(!check_forward_range<cpp17_input_iterator>());
38 static_assert(!check_forward_range<cpp20_input_iterator>());
39 static_assert(check_forward_range<forward_iterator>());
40 static_assert(check_forward_range<bidirectional_iterator>());
41 static_assert(check_forward_range<random_access_iterator>());
42 static_assert(check_forward_range<contiguous_iterator>());
43