9 Iterators library [iterators]

9.7 Iterator adaptors [iterators.predef]

9.7.4 Common iterators [iterators.common] common_iterator operations [common.iter.ops] common_iterator::operator-> [common.iter.op.ref]

decltype(auto) operator->() const requires see below;

Requires: !is_sentinel

Effects: Equivalent to:

  • If I is a pointer type or if the expression i.operator->() is well-formed, return iter;

  • Otherwise, if the expression *iter is a glvalue:

    auto&& tmp = *iter;
    return addressof(tmp);
  • Otherwise, return proxy(*iter); where proxy is the exposition-only class:

    class proxy {               // exposition only
      value_type_t<I> keep_;
      proxy(reference_t<I>&& x)
        : keep_(std::move(x)) {}
      const value_type_t<I>* operator->() const {
        return addressof(keep_);

The expression in the requires clause is equivalent to:

Readable<const I> &&
  (requires(const I& i) { i.operator->(); } ||
   is_reference<reference_t<I>>::value ||
   Constructible<value_type_t<I>, reference_t<I>>)