I'm attempting to use a hash class that I've developed within an std::map, and despite the fact that I've overloaded operator< I'm receiving the following error:
error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const ore::CEngine_BigHash<bytes,inputType>' (or there is no acceptable conversion)"
I'm using Visual C++ 2010, with the following overloaded operator:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class CEngine_BigHash
{
public:
...
booloperator < (const CEngine_BigHash & object)
{
for (Type_UnsignedInt16 i = 0; i < myBytesPerHash; i++)
{
if (myPtr_RawBytes[i] < object.myPtr_RawBytes[i])
returntrue;
}
returnfalse;
}
...
}
That looks like a global operator, so it needs to take two parameters. Either that or put your class_name:: in front of the operator name, if it is in fact supposed to be a method.
Your myPtr_RawBytes is an std::map, correct? If that's so, then, IIRC, you can't use it's operator[] because you have a const reference, and the array subscript allows you to modify the data.
I really need to get better at giving information. This issue isn't coming from within the operator itself, it's from comparing two BigHash objects within an std::map. myPtr_RawBytes is a statically allocated array of chars.