SHARE
TWEET

C++, can not copy 2 vectors to vector of pair

a guest Jan 19th, 2012 33 Never
  1. #include <vector>
  2. #include <map>
  3. #include <algorithm>
  4.  
  5.  
  6. struct Item { double a, b; Item (double a_, double b_): a(a_), b(b_){}};
  7. typedef std::pair <double, Item> TPair;
  8. typedef std::vector <TPair> TData;
  9.  
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13.     std::vector <double> t1;
  14.     std::vector <Item> t2;
  15.  
  16.     TData data;
  17.  
  18.     //Error
  19.     std::transform (t1.begin(), t1.end(), data.begin(),
  20.          std::bind2nd( std::ptr_fun( std::make_pair <double,Item > ), Item(0,0) ) );
  21. }
RAW Paste Data
Top