I have some code that compiles fine in VS 10.0 but after inserting a few items into the Orders map below I receive an "invalid operator <" error in Microsoft debug library. My less operator is simple, just compares the 8 byte string char by char. Anyone have any idea why I would receive this error?
typedef struct MY_orderID_t
{
char orderID[8];
} MY_orderID_t;
struct std::less<MY_orderID_t>
{
bool operator()(const MY_orderID_t& k1, const MY_orderID_t& k2) const
{
for( int i=0; i < 8; i++ )
{
if( k1.orderID[i] < k2.orderID[i] )
return( true );
}
return( false );
}
};
std::map< MY_orderID_t, MY_order_t > Orders[5];
Besides any other possible errors, which I don't see at the moment, this construct is not allowed:
std::less
is already a type, so you cannot redefine it as another type.