Title
generator::iterator::operator== should pass by reference
Status
c++23
Section
[coro.generator.iterator]
Submitter
Hewill Kang

Created on 2022-08-27.00:00:00 last changed 4 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to n4917.

  1. Modify [coro.generator.iterator] as indicated:

    namespace std {
      template<class Ref, class V, class Allocator>
      class generator<Ref, V, Allocator>::iterator {
      public:
        using value_type = value;
        using difference_type = ptrdiff_t;
    
        iterator(iterator&& other) noexcept;
        iterator& operator=(iterator&& other) noexcept;
        
        reference operator*() const noexcept(is_nothrow_copy_constructible_v<reference>);
        iterator& operator++();
        void operator++(int);
    
        friend bool operator==(const iterator& i, default_sentinel_t);
    
      private:
        coroutine_handle<promise_type> coroutine_; // exposition only
      };
    }
    

    […]

    friend bool operator==(const iterator& i, default_sentinel_t);
    

    -10- Effects: Equivalent to: return i.coroutine_.done();

Date: 2022-11-12.00:00:00

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

Date: 2022-09-15.00:00:00

[ 2022-09-23; Reflector poll ]

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

Date: 2022-09-03.15:46:27

Currently, generator::iterator::operator== passes iterator by value. Given that iterator is a move-only type, this makes it impossible for generator to model range, since default_sentinel cannot be compared to the iterator of const lvalue and is not eligible to be its sentinel.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13069
2022-11-17 00:42:33adminsetstatus: voting -> wp
2022-11-08 03:46:49adminsetstatus: ready -> voting
2022-09-23 15:43:32adminsetmessages: + msg12788
2022-09-23 15:43:32adminsetstatus: new -> ready
2022-09-03 15:44:18adminsetmessages: + msg12732
2022-08-27 00:00:00admincreate