I want to use boost::asio
to read in stdout
and stderr
from multiple boost::process
es simultaneously. However, I have compilation issues with boost::asio
and could reconstruct the following minimal example that does not compile:
#include <boost/asio.hpp>
#include <boost/asio/spawn.hpp>
int main() {
boost::asio::io_context ios;
boost::asio::spawn(ios,
[](boost::asio::yield_context ctx) {
});
ios.run();
return 0;
}
GCC 10.2.0
with C++17
enabled and linking to boost
version 1.72
results in the following:
In file included from /usr/include/boost/coroutine/coroutine.hpp:10,
from /usr/include/boost/coroutine/all.hpp:11,
from /usr/include/boost/asio/spawn.hpp:19,
from [...]/main.cpp:3:
/usr/include/boost/coroutine/asymmetric_coroutine.hpp: In function ‘typename boost::coroutines::pull_coroutine<R>::iterator boost::coroutines::begin(boost::coroutines::pull_coroutine<Arg>&)’
/usr/include/boost/coroutine/asymmetric_coroutine.hpp:2364:17: error: ‘begin’ is not a member of ‘boost’
2364 | { return boost::begin( c); }
Yeah this was an missing indirect include in a particular version of boost. See it live on wandbox .
Either
#include <boost/asio.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/asio/spawn.hpp>
int main() {
boost::asio::io_context ios;
boost::asio::spawn(ios,
[](boost::asio::yield_context ctx) {
});
ios.run();
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.