brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 21c73c9 Raw
43 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// std::ranges::borrowed_subrange_t;12 13#include <ranges>14 15#include <concepts>16#include <span>17#include <string>18#include <string_view>19#include <vector>20 21static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string>, std::ranges::dangling>);22static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string&&>, std::ranges::dangling>);23static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::vector<int> >, std::ranges::dangling>);24 25static_assert(26    std::same_as<std::ranges::borrowed_subrange_t<std::string&>, std::ranges::subrange<std::string::iterator> >);27 28static_assert(29    std::same_as<std::ranges::borrowed_subrange_t<std::span<int> >, std::ranges::subrange<std::span<int>::iterator> >);30 31static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string_view>,32                           std::ranges::subrange<std::string_view::iterator> >);33 34template <class T>35constexpr bool has_type = requires {36  typename std::ranges::borrowed_subrange_t<T>;37};38 39static_assert(!has_type<int>);40 41struct S {};42static_assert(!has_type<S>);43