1
我試圖將一個字符串映射到函數。該功能應該得到一個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'。 – StoryTeller