【发布时间】:2017-10-15 06:07:57
【问题描述】:
我正在尝试将字符串映射到函数。该函数应该得到一个 const char* 传入。我想知道为什么我一直收到
*no match for call to ‘(boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const char*), boost::_bi::list0>) (const char*)’*
我的代码在下面
#include <map>
#include <string>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/function.hpp>
typedef boost::function<void(const char*)> fun_t;
typedef std::map<std::string, fun_t> funs_t;
void $A(const char *msg)
{
std::cout<<"hello $A";
}
int main(int argc, char **argv)
{
std::string p = "hello";
funs_t f;
f["$A"] = boost::bind($A);
f["$A"](p.c_str());
return 0;
}
【问题讨论】:
-
我会提醒您不要使用非标准标识符,例如
$A。
标签: c++ function dictionary boost