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
klemens-morgenstern added a commit that referenced this issue Aug 26, 2024
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* fix promise & generator operator=

* added fno-exceptions support.

* added experimental context support.

* support for asio::yield_context

* Add missing NO_LIB usage requirements.

* added noop utility

closes #3

* added support for __cpp_sized_deallocation in custom coroutine allocations.

(non-apple) clang is weird, as it allowed sized deallocations on coroutine promises even when not enabled otherwise.
Since apple does not, this should fix using cobalt on apple.

* Add missing import-search for cconfig/predef checks.

* Add requires-b2 check to top-level build file.

* Update dependencies.

* Fix -Wreorder flagging

If using -Werror=reorder via some cmake build or otherwise, this gets flagged.

* added move support for channels

Closes #183

* fixed ctor so any works.

Closes #182

* added noinline ot channel functions when compiling for windows.

* removed move_only template inst from channel.cpp

* Declared test targets with EXCLUDE_FROM_ALL

Closes #181.

* added generate-diagram option & cache

* Cleaned up CML.

Closes #135.

* Bump B2 require to 5.2

* Move inter-lib dependencies to a project variable and into the build targets.

* Move custom features to importable jam.

---------

Co-authored-by: Klemens Morgenstern <[email protected]>
Co-authored-by: Jonathan Stein <[email protected]>
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