Skip to content

Commit f6e6d27

Browse files
committed
Deleted copy ctor/assign op on generator, implement rule of 5
1 parent 27c2a1b commit f6e6d27

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

inc/generator.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,33 @@ template <std::copyable T> class generator {
250250
* \param[in] p The promise to use.
251251
*/
252252
generator(promise_type &p) : _h{handle_type::from_promise(p)} {}
253+
254+
/**
255+
* \brief Copy-constructing generators results in undefined behaviour.
256+
*/
257+
generator(const generator &other) = delete;
258+
/**
259+
* \brief Moves the data from the other generator into this one.
260+
* \param[in,out] other The other generator.
261+
*/
262+
generator(generator &&other) = default;
263+
264+
/**
265+
* \brief Copy-assigning generators results in undefined behaviour.
266+
*/
267+
generator &operator=(const generator &other) = delete;
268+
/**
269+
* \brief Moves the data from the other generator into this one.
270+
* \param[in,out] other The other generator.
271+
* \returns A reference to this generator.
272+
*/
273+
generator &operator=(generator &&other) = default;
274+
275+
/**
276+
* \brief Cleans up this generator's resources.
277+
*/
278+
~generator() = default;
279+
253280
/**
254281
* \brief Converts this generator its handle.
255282
* \returns The handle for this generator.

0 commit comments

Comments
 (0)