I have this simple piece of code that uses boost::bind:
#include <boost/bind.hpp>
#include <utility>
#include <vector>
#include <iterator>
#include <algorithm>
int main()
{
std::vector<int> a;
std::vector<std::pair<bool,int> > b;
a.push_back(1);
a.push_back(2);
a.push_back(3);
std::transform(a.begin(), a.end(), std::back_inserter(b),
boost::bind(std::make_pair<bool, int>, false, _1));
}
I'm getting a ton of errors in VS2010 RC, such as:
Error 1 error C2780: 'boost::_bi::bind_t<_bi::dm_result<MT::* ,A1>::type,boost::_mfi::dm<M,T>,_bi::list_av_1<A1>::type> boost::bind(M T::* ,A1)' : expects 2 arguments - 3 provided c:\projects\testtuple\main.cpp 18
Error 2 error C2780: 'boost::_bi::bind_t<Rt2,boost::_mfi::cmf8<R,T,B1,B2,B3,B4,B5,B6,B7,B8>,_bi::list_av_9<A1,A2,A3,A4,A5,A6,A7,A8,A9>::type> boost::bind(boost::type<T>,R (__thiscall T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 3 provided c:\projects\testtuple\main.cpp 18
Am I doing something wrong? If this is a bug in the compiler, how can I workaround it?
EDIT: added the entire test case.
Clarification: the code compiles in VS2008.
Update:
The problem is that make_pair
seems to be overloaded in the STL that ships with VS2010 (it wasn't in previous versions of VS or in GCC). The workaround is to make explicit which of the overloads you want, with a cast:
#include <boost/bind.hpp>
#include <utility>
#include <vector>
#include <iterator>
#include <algorithm>
int main()
{
std::vector<int> a;
std::vector<std::pair<bool,int> > b;
a.push_back(1);
a.push_back(2);
a.push_back(3);
typedef std::pair<bool, int> (*MakePairType)(bool, int);
std::transform(a.begin(), a.end(), std::back_inserter(b),
boost::bind((MakePairType)&std::make_pair<bool, int>,
false, _1));
}
For additional details see the Boost bind manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With