Junior — Senior
Using Data structure as a key for std::set and std::unordered_set
livecode
Task condition
It is necessary to make the user-defined structure Data usable as a key in both an ordered container std::set and an unordered container std::unordered_set. To do this, you should implement the required comparison operators and hash function, after which the code example will compile and work successfully.
#include <set>
#include <iostream>
#include <unordered_set>
struct Data {
int value;
};
int main(int argc, char** argv)
{
std::set<Data> dataSet;
std::unordered_set<Data> dataUSet;
return EXIT_SUCCESS;
}