[range.iota.view] (original) (raw)

25 Ranges library [ranges]

25.6 Range factories [range.factories]

25.6.4 Iota view [range.iota]

25.6.4.2 Class template iota_view [range.iota.view]

namespace std::ranges { template<class I> concept decrementable = see below; template<class I> concept advanceable = see below; template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t> requires weakly-equality-comparable-with<W, Bound> && copyable<W> class iota_view : public view_interface<iota_view<W, Bound>> { private: struct iterator; struct sentinel; W value_ = W(); Bound bound_ = Bound(); public: iota_view() requires default_initializable<W> = default;constexpr explicit iota_view(W value);constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);constexpr explicit iota_view(iterator first, see below last);constexpr iterator begin() const;constexpr auto end() const;constexpr iterator end() const requires same_as<W, Bound>;constexpr bool empty() const;constexpr auto size() const requires see below;};template<class W, class Bound> requires (!is-integer-like<W> || !is-integer-like<Bound> || (is-signed-integer-like<W> == is-signed-integer-like<Bound>)) iota_view(W, Bound) -> iota_view<W, Bound>;}

Let IOTA-DIFF-T(W) be defined as follows:

The exposition-only decrementable concept is equivalent to:

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

The exposition-only advanceable concept is equivalent to:

template<class I> concept [_advanceable_](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]") = // _exposition only_ [_decrementable_](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<I> && [totally_ordered](concept.totallyordered#concept:totally%5Fordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<I> && requires(I i, const I j, const _IOTA-DIFF-T_(I) n) { { i += n } -> [same_as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<I&>;{ i -= n } -> [same_as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<I&>; I(j + n); I(n + j); I(j - n);{ j - j } -> [convertible_to](concept.convertible#concept:convertible%5Fto "18.4.4 Concept convertible_­to [concept.convertible]")<_IOTA-DIFF-T_(I)>;};

Let D be IOTA-DIFF-T(I).

Let a and b be objects of type I such thatb is reachable from aafter n applications of ++a, for some value n of type D.

I models advanceable only if

constexpr explicit iota_view(W value);

Preconditions: Bound denotes unreachable_sentinel_t orBound() is reachable from value.

Effects: Initializes value_ with value.

constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);

Preconditions: Bound denotes unreachable_sentinel_t orbound is reachable from value.

Effects: Initializes value_ with value and_bound__ with bound.

constexpr explicit iota_view(_iterator_ first, _see below_ last);

Effects: Equivalent to:

Remarks: The type of last is:

constexpr _iterator_ begin() const;

Effects: Equivalent to: return iterator{value_};

constexpr auto end() const;

Effects: Equivalent to:if constexpr (same_as<Bound, unreachable_sentinel_t>) return unreachable_sentinel;else return sentinel{bound_};

constexpr _iterator_ end() const requires [same_as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<W, Bound>;

Effects: Equivalent to: return iterator{bound_};

constexpr bool empty() const;

Effects: Equivalent to: return value_ == bound_;

constexpr auto size() const requires _see below_;

Effects: Equivalent to:if constexpr (is-integer-like<W> && is-integer-like<Bound>) return (value_ < 0) ? ((bound_ < 0) ? to-unsigned-like(-value_) - to-unsigned-like(-bound_) : to-unsigned-like(bound_) + to-unsigned-like(-value_)) : to-unsigned-like(bound_) - to-unsigned-like(value_);else return to-unsigned-like(bound_ - value_);