#include <bits/stdc++.h>
using namespace std;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
/*const long long RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();*/
struct HASH {
template <class T>
std::size_t operator()(T x) const {
return hash<T>{}(x ^ RANDOM );
}
};
int main(int argc, char const *argv[])
{
unordered_map<int, int, HASH> table;
/* unordered_map<long long, int, HASH> table; */
return 0;
}
If my map key is int
type I've to write const int RANDOM
If my map key is long long
type I've to write const long long RANDOM
blah blah ......
How it can be better using Template?