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 // class std::ranges::subrange; 14 15 #include <ranges> 16 17 #include <cassert> 18 #include "test_macros.h" 19 #include "test_iterators.h" 20 21 template<std::ranges::subrange_kind K, class... Args> 22 concept ValidSubrangeKind = requires { typename std::ranges::subrange<Args..., K>; }; 23 24 template<class... Args> 25 concept ValidSubrange = requires { typename std::ranges::subrange<Args...>; }; 26 27 static_assert( ValidSubrange<forward_iterator<int*>>); 28 static_assert( ValidSubrange<forward_iterator<int*>, forward_iterator<int*>>); 29 static_assert( ValidSubrangeKind<std::ranges::subrange_kind::unsized, forward_iterator<int*>, forward_iterator<int*>>); 30 static_assert( ValidSubrangeKind<std::ranges::subrange_kind::sized, forward_iterator<int*>, forward_iterator<int*>>); 31 // Wrong sentinel type. 32 static_assert(!ValidSubrange<forward_iterator<int*>, int*>); 33 static_assert( ValidSubrange<int*>); 34 static_assert( ValidSubrange<int*, int*>); 35 // Must be sized. 36 static_assert(!ValidSubrangeKind<std::ranges::subrange_kind::unsized, int*, int*>); 37 static_assert( ValidSubrangeKind<std::ranges::subrange_kind::sized, int*, int*>); 38 // Wrong sentinel type. 39 static_assert(!ValidSubrange<int*, forward_iterator<int*>>); 40 // Not an iterator. 41 static_assert(!ValidSubrange<int>); 42