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