Fix unintended shallow copying when used with std::views::take (issue 261)#263
Conversation
|
The following patch adds a compiler error message: diff --git a/include/coro/generator.hpp b/include/coro/generator.hpp
index a15305a..020bf21 100644
--- a/include/coro/generator.hpp
+++ b/include/coro/generator.hpp
@@ -127,7 +127,7 @@ public:
generator() noexcept : m_coroutine(nullptr) {}
- generator(const generator&) = delete;
+ generator(const generator&) { static_assert(false, "copying is not supported"); }
generator(generator&& other) noexcept : m_coroutine(other.m_coroutine) { other.m_coroutine = nullptr; }
auto operator=(const generator&) = delete;which looks like this: Which is still ugly, but I think it's better than without: |
|
Really sorry how slow I've been to respond, life is a little wild right now. Thank you for opening the PR, we'll get this fixed. |
|
Thanks for adding tests already, it looks like the macos build in generally might be broken right now |
|
I've merged a fix for the macos failures if you want to rebase and re-run the CI |
Enables `view` concept on `generator` so that lvalue references cannot be accepts by `std::views:take`, which in turn would lead to erronious behavior.
afd80a7 to
eb52dfb
Compare
|
@jbaldwin I have rebased to the new main as requested. |
|
Yeah lets go ahead and add it in please. |
…ove compiler error messages
|
@jbaldwin I think I am done with this :-) |
|
Looks like it's uncovered some failing tests now if you could take a look at them. |
This reverts commit 12f738c.
|
I see, the older GCC (<13) compiler treats |
Enables
viewconcept ongeneratorso that lvalue references cannot be accepted bystd::views:take, which in turn would lead to erroneous behavior described in issue 261.