This works fine, if i declare a pair of <double, int>
Code:
std::vector< pair<double,int> >test;
test.push_back(pair<double,int>(0.1,3));
test.push_back(pair<double,int>(0.3,6));
test.push_back(pair<double,int>(0.2,75));
sort(test.begin(),test.end());
However when i used a pair of <double, CvPoint>, where CvPoint is a opencv struct, the compiler complains of
Code:
error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const CvPoint'
1> c:\program files\microsoft visual studio 9.0\vc\include\vector(1320) : see declaration of 'std::operator <'
Is it possible to use a structure in a vector pair?
Heres the code:
Code:
struct CvPoint{
int x;
int y;
}
std::vector< pair<double,CvPoint> >test;
test.push_back(pair<double,CvPoint>(0.1,cvPoint(1,2)));
test.push_back(pair<double,CvPoint>(0.3,cvPoint(2,4)));
test.push_back(pair<double,CvPoint>(0.2,cvPoint(3,6)));
sort(test.begin(),test.end());