Alexander Shyrokov wrote:
Thanks Peter,
But how exactly do I specify _1? I have the same error if I do not specify any name space (as it is shown in the example)
boost::_1 is not defined boost::bind::_1 generates "fatal error C1001: INTERNAL COMPILER ERROR"
I do not know which error I like the best :)
This is the code:
#include <vector> #include <algorithm> #include <boost/bind.hpp>
int main(int argc, char **argv) { typedef std::vector<std::vector<bool> > T2Dimensional; T2Dimensional vec; std::for_each(vec.begin(),vec.end() ,boost::bind(&std::vector<bool>::resize,_1,10)); return 0; }
Your code is fine, sort of. The problem is that vector<>::resize takes two arguments. The second one has a default, but this information is lost when the pointer to member &std::vector<bool>::resize is taken. So you have to pass a value for it. std::for_each(vec.begin(),vec.end() ,boost::bind( &std::vector<bool>::resize, _1, 10, false ) );