Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | ranges
 
 
 
Defined in header <ranges>
template<ranges::range R>

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

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

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

    ranges::subrange<ranges::iterator_t<R>>, ranges::dangling>;
(2) (since C++20)
1) Same as ranges::iterator_t when R models borrowed_range, otherwise yields ranges::dangling instead.
2) Similar to (1), but it yields a specialization of ranges::subrange when the same condition is met.

These two alias templates are used by some constrained algorithms to avoid returning potentially dangling iterators or views.

[edit] See also

a placeholder type indicating that an iterator or a subrange should not be returned since it would be dangling
(class) [edit]