boost asio channels “no type named ‘receive_cancelled_signature'”
Simpler repro: Live On Coliru
#include <boost/asio/experimental/channel.hpp>
#include <boost/asio/system_executor.hpp>
using Channel = boost::asio::experimental::channel<void(std::error_code, size_t)>;
int main() {
Channel c(boost::asio::system_executor{});
}
shared_ptr
, A
, list
and the loop had nothing to do with it.
Your mistake is that you use std::error_code
which isn’t supported by default.
Standalone Asio does use std::error_code
, and perhaps Boost Asio can be configured to do so.
Keep in mind that Boost System has more features, and excellent interop with std::error_code these days.
Fix
Use boost::system::error_code
:
#include <boost/asio.hpp>
#include <boost/asio/experimental/channel.hpp>
#include <iostream>
#include <list>
using Channel = boost::asio::experimental::channel<void(boost::system::error_code, size_t)>;
int main() {
boost::asio::io_context ctx;
std::list<Channel> channels;
for (auto n = 5; n--;)
channels.emplace_back(ctx);
for (Channel& ch : channels) {
std::cout << "Ch at address " << &ch << std::endl;
}
}
Prints e.g.
Ch at address 0x2047d90
Ch at address 0x2048130
Ch at address 0x2048470
Ch at address 0x20487b0
Ch at address 0x2048af0
Read more here: Source link