All the libraries defined below are included in the header <ranges> and <iterator>.
std::ranges::iterator_t
It is used to obtain the iterator of type t (t is a type that can be used in std::ranges::begin)
template <class t>
using iterator_t = decltype(ranges::begin(declval<t&>()));
std::ranges::safe_iterator_t
It returns the iterator type of R wrapped in Dangling(described in my previous articles) if the range was an rvalue range
They are used by range algorithms that accept rvalue ranges and return iterators into them.
IN OTHER WORDS,
template<Range R>
using safe_iterator_t = std::conditional_t<__ForwardingRange<R>,
ranges::iterator_t<R>, ranges::dangling>;
using safe_subrange_t = std::conditional_t<__ForwardingRange<R>,
ranges::subrange<ranges::iterator_t<R>>, ranges::dangling>;
Comments