Difference between revisions of "cpp/ranges/borrowed iterator t"
From cppreference.com
m (T. Canens moved page cpp/ranges/safe iterator t to cpp/ranges/borrowed iterator t: Text replace - "safe (range|subrange|iterator)" to "borrowed $1") |
m (Added Spanish link) |
||
Line 27: | Line 27: | ||
{{dsc end}} | {{dsc end}} | ||
− | {{langlinks|ja|zh}} | + | {{langlinks|es|ja|zh}} |
Revision as of 07:14, 4 March 2020
Defined in header <ranges>
|
||
template<ranges::range R> using borrowed_iterator_t = std::conditional_t<ranges::borrowed_range<R>, |
(1) | (since C++20) |
template<ranges::range R> using borrowed_subrange_t = std::conditional_t<ranges::borrowed_range<R>, |
(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 the same condition is met.
These two alias templates are used by some constrained algorithms to avoid returning potentially dangling iterators or views.
See also
(C++20) |
a placeholder type indicating that an iterator or a subrange should not be returned since it would be dangling (class) |