Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-09-13 15:51:15


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 ) );


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net