J'essaie de mapper une chaîne à une fonction. La fonction doit avoir un const char*
passé. Je me demande pourquoi je continue à obtenir l'erreur queBooster la carte de fonction à la chaîne
*no match for call to ‘(boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const char*), boost::_bi::list0>) (const char*)’*
Mon code est ci-dessous
#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;
}
Je vous mets en garde contre l'utilisation d'identifiants non standards comme '$ A'. – StoryTeller