samedi 3 octobre 2015

boost::unordered_set of char16_t strings

Why does following

#include <string>
#include <boost/unordered_set.hpp>

int main()
{    
    typedef boost::unordered_set<std::string> unordered_set;
    unordered_set animals;

    animals.emplace("cat");
    animals.emplace("shark");
    animals.emplace("spider");
    return 0;
}

work and following results in too many compilation errors.

#include <string>
#include <boost/unordered_set.hpp>

int main()
{    
    typedef boost::unordered_set<std::u16string> unordered_set;
    unordered_set animals;

    animals.emplace("cat");
    animals.emplace("shark");
    animals.emplace("spider");
    return 0;
}

Also, what's the solution for this ? Do I need to write my own hash_function and operator== in function objects as mentioned here ?

Aucun commentaire:

Enregistrer un commentaire