4
votes

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.

1
std::placeholders::_1Xeo

1 Answers

12
votes

In your case, you want this:

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