I am trying to use a struct as a key for an unordered_map
. I added the 'spaceship' operator to the structure, which solved errors I was getting with normal comparisons, such as "is struct 1 greater than struct 2?", etc. However, I am getting attempting to reference a deleted function
when using it as a key for my map. From what understood, adding the spaceship operator should have allowed me to use the struct as the map key. What is wrong?
struct test
{
uint32_t a;
uint32_t b;
auto operator<=>(const test&) const = default;
};
std::unordered_map<test, uint32_t> x; // Causes error