brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 909fff3 Raw
66 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// template<class R>12//   drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;13 14#include <cassert>15#include <concepts>16#include <ranges>17#include <utility>18 19struct View : std::ranges::view_base {20  int *begin() const;21  int *end() const;22};23 24struct Range {25  int *begin() const;26  int *end() const;27};28 29struct BorrowedRange {30  int *begin() const;31  int *end() const;32};33template<>34inline constexpr bool std::ranges::enable_borrowed_range<BorrowedRange> = true;35 36void testCTAD() {37    View v;38    Range r;39    BorrowedRange br;40 41    static_assert(std::same_as<42        decltype(std::ranges::drop_view(v, 0)),43        std::ranges::drop_view<View>44    >);45    static_assert(std::same_as<46        decltype(std::ranges::drop_view(std::move(v), 0)),47        std::ranges::drop_view<View>48    >);49    static_assert(std::same_as<50        decltype(std::ranges::drop_view(r, 0)),51        std::ranges::drop_view<std::ranges::ref_view<Range>>52    >);53    static_assert(std::same_as<54        decltype(std::ranges::drop_view(std::move(r), 0)),55        std::ranges::drop_view<std::ranges::owning_view<Range>>56    >);57    static_assert(std::same_as<58        decltype(std::ranges::drop_view(br, 0)),59        std::ranges::drop_view<std::ranges::ref_view<BorrowedRange>>60    >);61    static_assert(std::same_as<62        decltype(std::ranges::drop_view(std::move(br), 0)),63        std::ranges::drop_view<std::ranges::owning_view<BorrowedRange>>64    >);65}66