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 std::any #182

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

cobalt::channel does not work with std::any #182

dchansen opened this issue May 24, 2024 · 0 comments

Comments

@dchansen
Copy link

The cobalt::channel fails to compile with std any, due to an ambiguous overload in the internal circular buffer.

The following code

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

namespace bc = boost::cobalt;

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

produces the error

In file included from /opt/compiler-explorer/libs/boost_1_84_0/boost/cobalt/channel.hpp:284,
                 from /opt/compiler-explorer/libs/boost_1_84_0/boost/cobalt.hpp:12,
                 from <source>:1:
/opt/compiler-explorer/libs/boost_1_84_0/boost/cobalt/impl/channel.hpp: In instantiation of 'boost::cobalt::channel<T>::channel(std::size_t, boost::cobalt::executor, std::pmr::memory_resource*) [with T = std::any; std::size_t = long unsigned int; boost::cobalt::executor = boost::asio::any_io_executor]':
<source>:7:27:   required from here
    7 |     bc::channel<std::any> c;
      |                           ^
/opt/compiler-explorer/libs/boost_1_84_0/boost/cobalt/impl/channel.hpp:25:7: error: call of overloaded 'circular_buffer(std::size_t&, std::pmr::memory_resource*&)' is ambiguous
   25 |     : buffer_(limit, resource), executor_(executor) {}
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/compiler-explorer/libs/boost_1_84_0/boost/circular_buffer.hpp:58,
                 from /opt/compiler-explorer/libs/boost_1_84_0/boost/cobalt/channel.hpp:17:
/opt/compiler-explorer/libs/boost_1_84_0/boost/circular_buffer/base.hpp:1056:5: note: candidate: 'boost::circular_buffer<T, Alloc>::circular_buffer(size_type, param_value_type, const allocator_type&) [with T = std::any; Alloc = std::pmr::polymorphic_allocator<std::any>; size_type = long unsigned int; param_value_type = const std::any&; allocator_type = std::pmr::polymorphic_allocator<std::any>]'
 1056 |     circular_buffer(size_type n, param_value_type item, const allocator_type& alloc = allocator_type())
      |     ^~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/boost_1_84_0/boost/circular_buffer/base.hpp:1037:14: note: candidate: 'boost::circular_buffer<T, Alloc>::circular_buffer(capacity_type, const allocator_type&) [with T = std::any; Alloc = std::pmr::polymorphic_allocator<std::any>; capacity_type = long unsigned int; allocator_type = std::pmr::polymorphic_allocator<std::any>]'
 1037 |     explicit circular_buffer(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type())
      |              ^~~~~~~~~~~~~~~
Compiler returned: 1

Godbolt link

klemens-morgenstern added a commit that referenced this issue May 27, 2024
klemens-morgenstern added a commit that referenced this issue May 27, 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

1 participant