I'm trying to get a STL map in C++ working with custom scalar objects so that I can use the scalar class in a map for OpenCV. I'm getting the following error:
error: ‘template class std::map’ used without template parameters
and this is the template im using:
template<typename _Tp> class MyScalar_ : public Scalar_<_Tp>{
public:
MyScalar_();
MyScalar_(Scalar_<_Tp>& s){
_s = s;
};
_Tp& operator[](const int idx){
return _s[idx];
}
//std::less<_Tp>::operator()(const _Tp&, const _Tp&) const
//this wont work if scalars are using doubles
bool operator < (const MyScalar_<_Tp>& obj) const {
double lhs,rhs;
lhs = _s[0] + _s[1] + _s[2] + _s[3];
rhs = _s[0] + _s[1] + _s[2] + _s[3];
return lhs > rhs;
}
bool operator == (const MyScalar_<_Tp>& obj) const{
bool valid = true;
for(int i = 0;i<_s.size();i++){
if(_s[i] != obj[i])
return false;
}
return valid;
}
private:
Scalar_<_Tp> _s;
};
I have std::map< MyScalar,Point > edgeColorMap;
in my header file as well
the error above states that the line:
auto tempit = edgeColorMap.find(s);
if(tempit != std::map::end){//found a color that this pixel relates to
fails at the if statement and I can't figure out why??