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