Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cobalt::channel does not work with move only type #183

Closed
dchansen opened this issue May 24, 2024 · 2 comments
Closed

cobalt::channel does not work with move only type #183

dchansen opened this issue May 24, 2024 · 2 comments

Comments

@dchansen
Copy link

The channel class requires that the value type be copyable, so things like unique_ptrs cannot be used with it.

This example (for instance) does not compile:

#include <boost/cobalt.hpp>
#include <any>
#include <memory>

namespace bc = boost::cobalt;

struct OnlyOne {
    OnlyOne() = default;
    OnlyOne(const OnlyOne&) = delete;
    OnlyOne( OnlyOne&&) = default;
};


bc::task<void> test(){
    bc::channel<OnlyOne> c;
    co_await c.write(OnlyOne());       
}

See godbolt

klemens-morgenstern added a commit that referenced this issue May 27, 2024
@klemens-morgenstern
Copy link
Collaborator

Thanks for reporting. I created fixes for both your issues, can you check if they fix all problems?

@dchansen
Copy link
Author

Thanks for the quick response. Your patch fixed both issues.

klemens-morgenstern added a commit that referenced this issue May 30, 2024
klemens-morgenstern added a commit that referenced this issue Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants