I am developing a SNMP Agent in Windows. In the header file snmp.h there is a struct which defines the OID identifier for a value and the definition for that is as follows:
typedef struct {
  UINT   idLength;
  UINT * ids;
} AsnObjectIdentifier; 
I want to use this AsnObjectIdentifier as a key to an unordered_map but the struct definition does not overload the == operator, which brings me to the question whether if it is possible to add an operator overload to an already defined struct or would I have to just have my custom struct wrapping the AsnObjectIdentifier variable. 
Yes, you can define operators outside of the class:
bool operator==(AsnObjectIdentifier const& lhs, AsnObjectIdentifier const& rhs)
{
    return /* whatever */;
}
Alternatively you can define a custom equality function object and pass it to unordered_map's fourth template parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With