[coro.generator.members] # 25 Ranges library [[ranges]](./#ranges) ## 25.8 Range generators [[coro.generator]](coro.generator#members) ### 25.8.4 Members [coro.generator.members] [🔗](#lib:generator,constructor) `generator(generator&& other) noexcept; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18169) *Effects*: Initializes *coroutine_* withexchange(other.*coroutine_*, {}) and*active_* withexchange(​other.*active_*, nullptr)[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18176) [*Note [1](#note-1)*: Iterators previously obtained from other are not invalidated; they become iterators into *this[.](#2.sentence-1) — *end note*] [🔗](#lib:generator,destructor) `~generator(); ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18189) *Effects*: Equivalent to:if (*coroutine_*) {*coroutine_*.destroy();} [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18198) [*Note [2](#note-2)*: Ownership of recursively yielded generators is held in awaitable objects in the coroutine frame of the yielding generator, so destroying the root generator effectively destroys the entire stack of yielded generators[.](#4.sentence-1) — *end note*] [🔗](#lib:operator=,generator) `generator& operator=(generator other) noexcept; ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18214) *Effects*: Equivalent to:swap(*coroutine_*, other.*coroutine_*); swap(*active_*, other.*active_*); [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18222) *Returns*: *this[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18226) [*Note [3](#note-3)*: Iterators previously obtained from other are not invalidated; they become iterators into *this[.](#7.sentence-1) — *end note*] [🔗](#lib:begin,generator) `iterator begin(); ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18239) *Preconditions*: *coroutine_* refers to a coroutine suspended at its initial suspend point ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4 Coroutine definitions"))[.](#8.sentence-1) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18244) *Effects*: Pushes *coroutine_* into **active_*, then evaluates *coroutine_*.resume()[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18249) *Returns*: An *iterator* object whose member *coroutine_* refers to the same coroutine as does*coroutine_*[.](#10.sentence-1) [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18256) [*Note [4](#note-4)*: A program that calls begin more than once on the same generator has undefined behavior[.](#11.sentence-1) — *end note*] [🔗](#lib:end,generator) `default_sentinel_t end() const noexcept; ` [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18269) *Returns*: default_sentinel[.](#12.sentence-1)