24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.12 Counted view [range.counted]

A counted view presents a view of the elements of the counted range ([iterator.requirements.general]) for an iterator i and non-negative integer n.
The name views​::​counted denotes a customization point object ([customization.point.object]).
Let E and F be expressions, and let T be decay_­t<decltype((E))>.
Then the expression views​::​counted(E, F) is expression-equivalent to:
  • If T models input_­or_­output_­iterator and decltype((F)) models convertible_­to<iter_­difference_­t<T>>,
    • subrange{E, E + static_­cast<iter_­difference_­t<T>>(F)} if T models random_­access_­iterator.
    • Otherwise, subrange{counted_­iterator{E, F}, default_­sentinel}.
  • Otherwise, views​::​counted(E, F) is ill-formed.
    : This case can result in substitution failure when views​::​counted(E, F) appears in the immediate context of a template instantiation. — end note