3595. Exposition-only classes proxy and postfix-proxy for common_iterator should be fully constexpr

Section: 24.5.5.4 [common.iter.access], 24.5.5.5 [common.iter.nav] Status: C++23 Submitter: Hewill Kang Opened: 2021-09-18 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [common.iter.access].

View all issues with C++23 status.

Discussion:

LWG 3574 added constexpr to all member functions and friends of common_iterator to make it fully constexpr, but accidentally omitted the exposition-only classes proxy and postfix-proxy defined for some member functions. We should make these two classes fully constexpr, too.

[2021-09-24; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4892.

  1. Modify 24.5.5.4 [common.iter.access] as indicated:

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

    -3- […]

    -4- […]

    -5- Effects:

    1. (5.1) — […]

    2. (5.2) — […]

    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_);
        }
      };
      
  2. Modify 24.5.5.5 [common.iter.nav] as indicated:

    decltype(auto) operator++(int);
    

    -4- […]

    -5- Effects: If I models forward_iterator, equivalent to:

    […]

    Otherwise, if […]

    […]

    Otherwise, equivalent to:

    postfix-proxy p(**this);
    ++*this;
    return p;
    

    where postfix-proxy is the exposition-only class:

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