boost::bind在许多情况下都非常方便。其中之一是分派/发布方法调用,以便io_service在以后可能的情况下进行调用。
在这种情况下,boost::bind的行为正如人们可能坦率地预期的那样:
#include <boost/asio.hpp>
#include <boost/bind.hpp>
boost::asio::io_service ioService;
class A {
public: A() {
// ioService will call B, which is private, how?
这是我第一次在C++中实现多线程。现在,我的代码抛出了某种我无法识别的错误,但它似乎表明,当我包含boost/thread.hpp时,它就会发生。
错误看起来像这样。
In file included
from /usr/include/boost/mem_fn.hpp:22:0,
from /usr/include/boost/bind/bind.hpp:26,
from /usr/include/boost/bind.hpp:22,
from /usr/include/boost
我想在我的程序中使用boost::thread,但得到以下编译器错误(Visual Studio 2005):
Error 1 **error C2064**: term does not evaluate to a function taking 0
arguments d:\...\boost_1_37_0\boost\thread\detail\thread.hpp 56
因此,我尝试在一个小程序中重现这个问题,并修改了中可用的Hello World示例。
我的测试代码现在如下所示。为什么它不能在类中工作?:
#include <boost/thread.hpp>
我试图通过使用map将std::for_each and boost::bind的所有键复制到另一个键中。
我收到编译错误的信息
error: no matching function for call to
‘bind(<unresolved overloaded function type>, boost::arg<1>&, boost::arg<1>&)’
在我的代码下面。
using namespace boost;
map<string,int32_t> A;
typedef map<string,s