lundi 29 octobre 2018

Unable to create unordered_set with lambda function

I get the error

error: call to implicitly-deleted default constructor of '__compressed_pair_elem<(lambda at 
main.cpp:181:16), 1>': _Base1(std::forward<_Tp>(__t)), _Base2() {}

with the following code. What's the mistake I am making and I couldn't understand the error as well.

using namespace std;

auto my_hash = [](vector<int> const& vec){
    size_t seed = vec.size();
    for(auto& i : vec) {
        seed ^= i + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }
    return seed;
};

using MySet = unordered_set<vector<int>, decltype(my_hash)>;

int main() {
    vector<int> a{1,2,3};
    MySet s;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire