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-has-no-incomplete-ranges 11 12 // template<class R> 13 // common_view(R&&) -> common_view<views::all_t<R>>; 14 15 #include <ranges> 16 #include <cassert> 17 18 #include "test_iterators.h" 19 20 struct View : std::ranges::view_base { 21 int *begin() const; 22 sentinel_wrapper<int*> end() const; 23 }; 24 25 struct Range { 26 int *begin() const; 27 sentinel_wrapper<int*> end() const; 28 }; 29 30 struct BorrowedRange { 31 int *begin() const; 32 sentinel_wrapper<int*> end() const; 33 }; 34 template<> 35 inline constexpr bool std::ranges::enable_borrowed_range<BorrowedRange> = true; 36 37 void testCTAD() { 38 View v; 39 Range r; 40 BorrowedRange br; 41 42 static_assert(std::same_as< 43 decltype(std::ranges::common_view(v)), 44 std::ranges::common_view<View> 45 >); 46 static_assert(std::same_as< 47 decltype(std::ranges::common_view(std::move(v))), 48 std::ranges::common_view<View> 49 >); 50 static_assert(std::same_as< 51 decltype(std::ranges::common_view(r)), 52 std::ranges::common_view<std::ranges::ref_view<Range>> 53 >); 54 static_assert(std::same_as< 55 decltype(std::ranges::common_view(std::move(r))), 56 std::ranges::common_view<std::ranges::owning_view<Range>> 57 >); 58 static_assert(std::same_as< 59 decltype(std::ranges::common_view(br)), 60 std::ranges::common_view<std::ranges::ref_view<BorrowedRange>> 61 >); 62 static_assert(std::same_as< 63 decltype(std::ranges::common_view(std::move(br))), 64 std::ranges::common_view<std::ranges::owning_view<BorrowedRange>> 65 >); 66 } 67