CppDS.com

C++ 98 11 14 17 20 手册

std::ranges::borrowed_iterator_t, std::ranges::borrowed_subrange_t

来自cppreference.com
< cpp‎ | ranges
定义于头文件 <ranges>
template<ranges::range R>

using borrowed_iterator_t = std::conditional_t<range::borrowed_range<R>,

    ranges::iterator_t<R>, ranges::dangling>;
(1) (C++20 起)
template<ranges::range R>

using borrowed_subrange_t = std::conditional_t<range::borrowed_range<R>,

    ranges::subrange<ranges::iterator_t<R>>, ranges::dangling>;
(2) (C++20 起)
1)R 实现概念 borrowed_range 时同 ranges::iterator_t ,否则替而生成 ranges::dangling
2) 类似 (1) ,但在满足相同条件时生成 ranges::subrange 的特化。

某些有制约算法用此二模板别名避免返回潜在悬垂的迭代器或视图。

参阅

占位类型,指示不应返回迭代器或子范围,因为它可能悬垂
(类)
关闭