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 11 // template<sized_range R> 12 // using range_size_t = decltype(ranges::size(declval<R&>())); 13 14 #include <ranges> 15 #include <concepts> 16 #include <cstddef> 17 18 #include "test_iterators.h" 19 20 template<class T> 21 concept has_range_size_t = requires { typename std::ranges::range_size_t<T>; }; 22 23 struct A { int *begin(); int *end(); short size(); }; 24 static_assert(std::same_as<std::ranges::range_size_t<A>, short>); 25 static_assert(std::same_as<std::ranges::range_size_t<A&>, short>); 26 static_assert(std::same_as<std::ranges::range_size_t<A&&>, short>); 27 static_assert(!has_range_size_t<const A>); 28 static_assert(!has_range_size_t<const A&>); 29 static_assert(!has_range_size_t<const A&&>); 30 31 struct B { int *begin(); int *end(); }; 32 static_assert(std::same_as<std::ranges::range_size_t<B>, std::size_t>); 33 static_assert(std::same_as<std::ranges::range_size_t<B&>, std::size_t>); 34 static_assert(std::same_as<std::ranges::range_size_t<B&&>, std::size_t>); 35 static_assert(!has_range_size_t<const B>); 36 static_assert(!has_range_size_t<const B&>); 37 static_assert(!has_range_size_t<const B&&>); 38 39 struct C { bidirectional_iterator<int*> begin(); bidirectional_iterator<int*> end(); }; 40 static_assert(!has_range_size_t<C>); 41