could not deduce template argument
c++, comparison, dictionary, key
Solution
Your `operator()` should be `operator<`:
bool operator<(const Cord& cord) const
{
if (x_cord == cord.x_cord)
{
return y_cord < cord.y_cord;
}
return x_cord < cord.x_cord;
}
`operator<` is what `std::map` uses to order its keys.
Problem
Part of the class I am implementing looks like this: ``` struct Cord { int x_cord; int y_cord; Cord(int x = 0,int y = 0):x_cord(x),y_cord(y) {} bool operator()(const Cord& cord) const { if (x_cord == cord.x_cord) { return y_cord < cord.y_cord; } return x_cord < cord.x_cord; } }; class Cell { }; std::map<Cord,Cell> m_layout; ``` I can`t compile the code above getting ``` error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const Layout::Cord' ``` Any advices?