Title
iter_move for common_iterator and counted_iterator should return decltype(auto)
Status
wp
Section
[common.iter.cust][counted.iter.cust]
Submitter
Hewill Kang

Created on 2023-06-30.00:00:00 last changed 12 months ago

Messages

Date: 2023-11-13.14:08:10

Proposed resolution:

This wording is relative to N4950.

  1. Modify [common.iterator], class template common_iterator synopsis, as indicated:

    namespace std {
      template<input_or_output_iterator I, sentinel_for<I> S>
        requires (!same_as<I, S> && copyable<I>)
      class common_iterator {
      public:
        […]
        friend constexpr iter_rvalue_reference_t<I>decltype(auto) iter_move(const common_iterator& i)
          noexcept(noexcept(ranges::iter_move(declval<const I&>())))
            requires input_iterator<I>;
        […]
      };
      […]
    }
    
  2. Modify [common.iter.cust] as indicated:

    friend constexpr iter_rvalue_reference_t<I>decltype(auto) iter_move(const common_iterator& i)
      noexcept(noexcept(ranges::iter_move(declval<const I&>())))
        requires input_iterator<I>;
    

    -1- Preconditions: […]

    -2- Effects: Equivalent to: return ranges::iter_move(get<I>(i.v_));

  3. Modify [counted.iterator], class template counted_iterator synopsis, as indicated:

    namespace std {
      template<input_or_output_iterator I>
      class counted_iterator {
      public:
        […]
        friend constexpr iter_rvalue_reference_t<I>decltype(auto) iter_move(const counted_iterator& i)
          noexcept(noexcept(ranges::iter_move(i.current)))
            requires input_iterator<I>;
        […]
      };
      […]
    }
    
  4. Modify [counted.iter.cust] as indicated:

    friend constexpr iter_rvalue_reference_t<I>decltype(auto) 
      iter_move(const counted_iterator& i)
        noexcept(noexcept(ranges::iter_move(i.current)))
        requires input_iterator<I>;
    

    -1- Preconditions: […]

    -2- Effects: Equivalent to: return ranges::iter_move(i.current);

Date: 2023-11-11.00:00:00

[ 2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP. ]

Date: 2023-10-15.00:00:00

[ 2023-10-27; Reflector poll ]

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

Date: 2023-06-30.00:00:00

Although the customized iter_move of both requires the underlying iterator I to be input_iterator, they still explicitly specify the return type as iter_rvalue_reference_t<I>, which makes it always instantiated.

From the point of view that its validity is only specified in the input_iterator concept, it would be better to remove such unnecessary type instantiation, which does not make much sense for an output_iterator even if it is still valid.

History
Date User Action Args
2023-11-13 14:08:10adminsetmessages: + msg13847
2023-11-13 14:08:10adminsetstatus: voting -> wp
2023-11-07 21:41:54adminsetstatus: ready -> voting
2023-10-27 21:22:44adminsetmessages: + msg13766
2023-10-27 21:22:44adminsetstatus: new -> ready
2023-07-02 10:03:39adminsetmessages: + msg13676
2023-06-30 00:00:00admincreate