I have a TMap which uses a custom type as a key. This type is based on two enums.
struct CustomType {
enum class EOne { A, B, C };
enum class ETwo { X, Y, Z };
EOne one;
ETwo two;
bool operator==(const CustomType& t) const {
return (one == t.one) && (two == t.two);
}
friend inline uint32 GetTypeHash(const CustomType& t) {
return (uint8_t)t.one + 3 + (uint8_t)t.two;
}
};
Say the TMap is called map
. It contains the following key:
{EOne::A, ETwo::Y}
When I run map.Contains({EOne:A, ETwo::X})
, true is returned even if it’s technically false. In fact, I get the value with the key containing {EOne::A, ETwo::Y}
instead. I don’t think that this a problem with my hash function, because the two keys won’t overwrite each other if I add them into the map.
Is there another function I need to be overwriting to get this working properly? What else could be the problem?