Pregunta

Well another troubling error message for me, if I understand std::bind correctly I can arguments like _1 to to the define a non-given argument? Right? Well considering the following line:

std::function<bool(value_type, const std::string &)> 
                             func(std::bind(&Pred, _1, "name"));

This should work, right? This would be used for a std::find_if() function, as such the first argument should be the value type & the second the string.

However visual studio 2010 complains about this with the following error message:

error C2065: '_1' : undeclared identifier

That's just weird, how can I say in visual studio "hey the first argument isn't bound". Pred is a simple funciton taking value_type, const std::string& as arguments - returning a boolean.

¿Fue útil?

Solución

In your case, you want this:

std::function<bool(value_type, const std::string &)> 
                         func(std::bind(&Pred, std::placeholders::_1, "name"));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top