23 Ranges library [ranges]

23.7 Range factories [range.factories]

23.7.3 Iota view [range.iota]

23.7.3.2 Class template iota_­view [range.iota.view]

namespace std::ranges {
  template<class I>
    concept Decrementable =     // exposition only
      see below;
  template<class I>
    concept Advanceable =       // exposition only
      see below;

  template<WeaklyIncrementable W, Semiregular Bound = unreachable_sentinel_t>
    requires weakly-equality-comparable-with<W, Bound>
  class iota_view : public view_interface<iota_view<W, Bound>> {
  private:
    struct iterator;            // exposition only
    struct sentinel;            // exposition only
    W value_ = W();             // exposition only
    Bound bound_ = Bound();     // exposition only
  public:
    iota_view() = default;
    constexpr explicit iota_view(W value);
    constexpr iota_view(type_identity_t<W> value,
                        type_identity_t<Bound> bound);

    constexpr iterator begin() const;
    constexpr sentinel end() const;
    constexpr iterator end() const requires Same<W, Bound>;

    constexpr auto size() const
      requires (Same<W, Bound> && Advanceable<W>) ||
               (Integral<W> && Integral<Bound>) ||
               SizedSentinel<Bound, W>
    { return bound_ - value_; }
  };

  template<class W, class Bound>
    requires (!Integral<W> || !Integral<Bound> || is_signed_v<W> == is_signed_v<Bound>)
  iota_view(W, Bound) -> iota_view<W, Bound>;
}
The exposition-only Decrementable concept is equivalent to:
template<class I> concept Decrementable = Incrementable<I> && requires(I i) { { --i } -> Same<I&>; { i-- } -> Same<I>; };
When an object is in the domain of both pre- and post-decrement, the object is said to be decrementable.
Let a and b be equal objects of type I.
I models Decrementable only if
  • If a and b are decrementable, then the following are all true:
  • If a and b are incrementable, then bool(--(++a) == b).
The exposition-only Advanceable concept is equivalent to:
template<class I> concept Advanceable = Decrementable<I> && StrictTotallyOrdered<I> && requires(I i, const I j, const iter_difference_t<I> n) { { i += n } -> Same<I&>; { i -= n } -> Same<I&>; { j + n } -> Same<I>; { n + j } -> Same<I>; { j - n } -> Same<I>; { j - j } -> Same<iter_difference_t<I>>; };
Let a and b be objects of type I such that b is reachable from a after n applications of ++a, for some value n of type iter_­difference_­t<I>, and let D be iter_­difference_­t<I>.
I models Advanceable only if
constexpr explicit iota_view(W value);
Expects: Bound denotes unreachable_­sentinel_­t or Bound() is reachable from value.
Effects: Initializes value_­ with value.
constexpr iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
Expects: Bound denotes unreachable_­sentinel_­t or bound is reachable from value.
Effects: Initializes value_­ with value and bound_­ with bound.
constexpr iterator begin() const;
Effects: Equivalent to: return iterator{value_­};
constexpr sentinel end() const;
Effects: Equivalent to: return sentinel{bound_­};
constexpr iterator end() const requires Same<W, Bound>;
Effects: Equivalent to: return iterator{bound_­};