xref: /llvm-project/libcxx/test/std/ranges/range.req/range.refinements/forward_range.compile.pass.cpp (revision f192616ce9835f427686b8a364c9cc53bf42447d)
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 
13 // template<class R>
14 // concept forward_range;
15 
16 #include <ranges>
17 
18 #include "test_iterators.h"
19 #include "test_range.h"
20 
21 namespace stdr = std::ranges;
22 
23 template <template <class...> class I>
24 constexpr bool check_forward_range() {
25   constexpr bool result = stdr::forward_range<test_range<I> >;
26   static_assert(stdr::forward_range<test_range<I> const> == result);
27   static_assert(stdr::forward_range<test_non_const_common_range<I> > == result);
28   static_assert(stdr::forward_range<test_non_const_range<I> > == result);
29   static_assert(stdr::forward_range<test_common_range<I> > == result);
30   static_assert(stdr::forward_range<test_common_range<I> const> == result);
31   static_assert(!stdr::forward_range<test_non_const_common_range<I> const>);
32   static_assert(!stdr::forward_range<test_non_const_range<I> const>);
33   return result;
34 }
35 
36 static_assert(!check_forward_range<cpp17_input_iterator>());
37 static_assert(!check_forward_range<cpp20_input_iterator>());
38 static_assert(check_forward_range<forward_iterator>());
39 static_assert(check_forward_range<bidirectional_iterator>());
40 static_assert(check_forward_range<random_access_iterator>());
41 static_assert(check_forward_range<contiguous_iterator>());
42