Date
2022-11-30.17:59:24
Message id
13134

Content

Proposed resolution:

This wording is relative to N4910.

  1. Modify [reverse.iter.elem] as indicated:

    constexpr pointer operator->() const
      requires (is_pointer_v<Iterator> ||
                requires(const Iterator i) { i.operator->(); });
    

    -2- Effects:

    1. (2.1) — If Iterator is a pointer type, equivalent to: return prev(current);

    2. (2.2) — Otherwise, equivalent to: return prev(current).operator->();

  2. Modify [common.iter.access] as indicated:

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

    -3- 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>>)
      

    -4- Preconditions: holds_alternative<I>(v_) is true.

    -5- Effects:

    1. (5.1) — If I is a pointer type or if the expression get<I>(v_).operator->() is well-formedrequires(I i) { i.operator->(); } is true, equivalent to: return get<I>(v_);

    2. (5.2) — Otherwise, if iter_reference_t<I> is a reference type, equivalent to:

        auto&& tmp = *get<I>(v_);
        return addressof(tmp);
        
    3. (5.3) — Otherwise, equivalent to: return proxy(*get<I>(v_)); where proxy is the exposition-only class:

        class proxy {
          iter_value_t<I> keep_;
          constexpr proxy(iter_reference_t<I>&& x)
            : keep_(std::move(x)) {}
        public:
          constexpr const iter_value_t<I>* operator->() const noexcept {
            return addressof(keep_);
          }
        };
        

    […]