dimanche 19 août 2018

How can I implement template here?

I'm using own hash function in unordered_map.I also want to template the variable "RANDOM" in following code.How it can be possible ?

#include <bits/stdc++.h>
using namespace std;

const int 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;

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire