STL:

STL
Last edited on
If someone could clarify/rectify the error
1
2
error: no match for 'operator<' (operand types are 'const KeyInfo' and 'const KeyInfo')
{ return __x < __y; } " 


It is simple.

If for some type foo following code not compiles:
1
2
foo x, y;
x < y;
Then this type cannot be used as key in map without either defining operator< or providing own comparator function to the map.
namespace std
{
template<> struct less<KeyInfo>
{
bool operator() (const KeyInfo& lhs, const KeyInfo& rhs)
{
return lhs.bits < rhs.bits;
}
};
}

Many thanks "MiiNiPaa (8057)" I added the above and it compiles now
Topic archived. No new replies allowed.