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, class T>
15 // concept output_range;
16 
17 #include <ranges>
18 
19 #include <iterator>
20 #include "test_iterators.h"
21 #include "test_range.h"
22 
23 struct T { };
24 
25 // Satisfied when it's a range and has the right iterator
26 struct GoodRange {
27     output_iterator<T*> begin();
28     sentinel end();
29 };
30 static_assert(std::ranges::range<GoodRange>);
31 static_assert(std::output_iterator<std::ranges::iterator_t<GoodRange>, T>);
32 static_assert(std::ranges::output_range<GoodRange, T>);
33 
34 // Not satisfied when it's not a range
35 struct NotRange {
36     output_iterator<T*> begin();
37 };
38 static_assert(!std::ranges::range<NotRange>);
39 static_assert( std::output_iterator<std::ranges::iterator_t<NotRange>, T>);
40 static_assert(!std::ranges::output_range<NotRange, T>);
41 
42 // Not satisfied when the iterator is not an output_iterator
43 struct RangeWithBadIterator {
44     cpp17_input_iterator<T const*> begin();
45     sentinel end();
46 };
47 static_assert( std::ranges::range<RangeWithBadIterator>);
48 static_assert(!std::output_iterator<std::ranges::iterator_t<RangeWithBadIterator>, T>);
49 static_assert(!std::ranges::output_range<RangeWithBadIterator, T>);
50