Defined in header <ranges> | ||
---|---|---|
template<Range R> using safe_iterator_t = std::conditional_t<__ForwardingRange<R>, ranges::iterator_t<R>, ranges::dangling>; | (1) | (since C++20) |
template<Range R> using safe_subrange_t = std::conditional_t<__ForwardingRange<R>, ranges::subrange<ranges::iterator_t<R>>, ranges::dangling>; | (2) | (since C++20) |
ranges::iterator_t
when R
models exposition-only concept __ForwardingRange
, otherwise yields ranges::dangling
instead.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.
a placeholder type indicating that an iterator or a subrange should not be returned since it would be dangling (class) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/ranges/safe_iterator_t