I have a complex struct i want to put as a key of the std::map to make a list of all unique objects fast:
union somecomplexstruct { struct { more_structs val1, val2; even_more_structs val3, val4; lots_of_more_structs val5; }; unsigned int DATA[3]; }; typedef map<somecomplexstruct, int, greater<somecomplexstruct> > somecomplexstructMap; But it says error: 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 somecomplexstruct'
How do i make my struct work there?
Edit: Got it working, thanks to everyone! Heres the code:
inline bool operator>(const somecomplexstruct &v1, const somecomplexstruct &v2){ if(v1.DATA[0] > v2.DATA[0]) return 1; if(v1.DATA[0] < v2.DATA[0]) return 0; if(v1.DATA[1] > v2.DATA[1]) return 1; if(v1.DATA[1] < v2.DATA[1]) return 0; return v1.DATA[2] > v2.DATA[2]; }
operator>is not good. Ifv1.DATA = {1,0,0}; v2.DATA = {0,1,0};, it claims that bothv1>v2andv2>v1.