There the following data types:
struct Item { double a, b; Item (double a_, double b_): a(a_), b(b_){}};
typedef std::pair <double, Item> TPair;
typedef std::vector <TPair> TData;
I want to copy 2 vectors into the vector of pairs:
int main(int argc, char* argv[])
{
std::vector <double> t1;
std::vector <Item> t2;
TData data;
//Error
std::transform (t1.begin(), t1.end(), data.begin(),
std::bind2nd( std::ptr_fun( std::make_pair <double,Item > ), double() ) );
}
But the compiler stops with the following error:
Error 1 error C2784: 'std::pointer_to_binary_function<_Arg1,_Arg2,_Result,_Result(__fastcall *)(_Arg1,_Arg2)>
std::ptr_fun(_Result (__fastcall *)(_Arg1,_Arg2))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
Error 2 error C2784: 'std::pointer_to_binary_function<_Arg1,_Arg2,_Result,_Result(__fastcall *)(_Arg1,_Arg2)>
std::ptr_fun(_Result (__fastcall *)(_Arg1,_Arg2))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
Where is the problem? Thanks for your help. Compiler MSVS 2010 x86. I prefer a solution without Boost.
Updated question
An error has been found by dasblinkenlight, the corrected code:
std::transform (t1.begin(), t1.end(), data.begin(), std::bind1st( std::ptr_fun( std::make_pair <double,Item > ), double() ) );
But compiler shows the same error…
The second argument of
make_pair<double,Item>isItem, notdouble:EDIT: For MS VS, I defined
make_pairas follows:Then the invocation looks like this: