23 Iterators library [iterators]

23.5 Iterator adaptors [predef.iterators]

23.5.4 Common iterators [iterators.common]

23.5.4.4 Accessors [common.iter.access]

decltype(auto) operator*(); decltype(auto) operator*() const requires dereferenceable<const I>;
Preconditions: holds_Β­alternative<I>(v_Β­).
Effects: Equivalent to: return *get<I>(v_Β­);
decltype(auto) operator->() const requires see below;
The expression in the requires clause is equivalent to:
indirectly_readable<const I> &&
(requires(const I& i) { i.operator->(); } ||
 is_reference_v<iter_reference_t<I>> ||
 constructible_from<iter_value_t<I>, iter_reference_t<I>>)
Preconditions: holds_Β­alternative<I>(v_Β­).
Effects:
  • If I is a pointer type or if the expression get<I>(v_Β­).operator->() is well-formed, equivalent to: return get<I>(v_Β­);
  • Otherwise, if iter_Β­reference_Β­t<I> is a reference type, equivalent to:
    auto&& tmp = *get<I>(v_);
    return addressof(tmp);
    
  • Otherwise, equivalent to: return proxy(*get<I>(v_Β­)); where proxy is the exposition-only class:
    class proxy {
      iter_value_t<I> keep_;
      proxy(iter_reference_t<I>&& x)
        : keep_(std::move(x)) {}
    public:
      const iter_value_t<I>* operator->() const {
        return addressof(keep_);
      }
    };