Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::generator<Ref,V,Allocator>::iterator

      From cppreference.com
      <cpp‎ |coroutine‎ |generator
       
       
      Utilities library
       
      Coroutine support
      Coroutine traits
      Coroutine handle
      No-op coroutines
      Trivial awaitables
      Range generators
      (C++23)
       
      Ranges library
      Range adaptors
       
       
      class/*iterator*/;
      (exposition only*)

      The return type ofgenerator::begin. Modelsindirectly_readable andinput_iterator.

      Contents

      [edit]Member types

      Member type Definition
      value_typestd::generator::value
      difference_typestd::ptrdiff_t

      [edit]Data members

      Member Description
      std::coroutine_handle<std::generator::promise_type>coroutine_ The coroutine handle
      (exposition-only member object*)

      [edit]Member functions

      constructs an iterator
      (public member function)
      assigns another iterator
      (public member function)
      returns an underlying value
      (public member function)
      advances the iterator
      (public member function)

      std::generator::iterator::iterator

      /*iterator*/(/*iterator*/&& other)noexcept;
      (since C++23)

      Initializescoroutine_ withstd::exchange(other.coroutine_,{});.

      std::generator::iterator::operator=

      /*iterator*/& operator=(/*iterator*/&& other)noexcept;
      (since C++23)

      Equivalent tocoroutine_=std::exchange(other.coroutine_,{});.

      Returns:*this.

      std::generator::iterator::operator*

      reference operator*()const
         noexcept(std::is_nothrow_copy_constructible_v<reference>);
      (since C++23)
      1. Letreference be thestd::generator's underlying type.
      2. Let for some generator objectx itscoroutine_ be in the stack*x.active_.
      3. Letx.active_->top() refer to a suspended coroutine with promise objectp.

      Equivalent toreturnstatic_cast<reference>(*p.value_);.

      std::generator::iterator::operator++

      constexpr/*iterator*/& operator++();
      (1)(since C++23)
      constexprvoid operator++(int);
      (2)(since C++23)
      1) Let for some generator objectx thecoroutine_ be in the stack*x.active_.
      Equivalent tox.active_->top().resume().
      Returns:*this.
      2) Equivalent to++*this;.

      [edit]Non-member functions

      (C++23)
      compares the underlying iterator with a sentinel
      (function)

      operator==(std::generator::iterator)

      friendbool operator==(const/*iterator*/& i,std::default_sentinel_t);
      (since C++23)

      Equivalent toreturn i.coroutine_.done();.

      The!= operator issynthesized fromoperator==.

      This function is not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup whenstd::generator::iterator is an associated class of the arguments.

      [edit]Example

      This section is incomplete
      Reason: no example
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/coroutine/generator/iterator&oldid=178292"

      [8]ページ先頭

      ©2009-2025 Movatter.jp