std::experimental::ranges::distance
<experimental/ranges/iterator>
constexpr /* unspecified */ distance = /* unspecified */;
(customization point object)
constexpr ranges::difference_type_t<I> distance( I first, S last );
constexpr ranges::difference_type_t<ranges::iterator_t <R>> distance( R&& r );
constexpr ranges::difference_type_t<ranges::iterator_t <R>> distance( R&& r );
Returns the distance between first and last, or between the beginning and the end of the range r.
[
first,
last)
does not denote a range, then I
and S
must be the same type and must model SizedSentinel
, and [
last,
first)
must denote a range. Otherwise, the behavior is undefined.Instantiating overloads (2,3) may be ill-formed if the header <experimental/ranges/range> is not included before the point of instantiation.
[edit] Customization point objects
The name ranges::distance
denotes a customization point object, which is a function object of a literal Semiregular
class type (denoted, for exposition purposes, as DistanceT
). All instances of DistanceT
are equal. Thus, ranges::distance
can be copied freely and its copies can be used interchangeably.
Given a set of types Args...
, if std::declval <Args>()... meet the requirements for arguments to ranges::distance
above, DistanceT
will satisfy ranges::Invocable<const DistanceT, Args...>. Otherwise, no function call operator of DistanceT
participates in overload resolution.
In every translation unit in which ranges::distance
is defined, it refers to the same instance of the customization point object. (This means that it can be used freely in things like inline functions and function templates without violating the one-definition rule.)
[edit] Return value
The distance between first and last, or between the beginning and the end of the range r.
[edit] Example
Reason: no example