dimanche 3 avril 2016

std::unordered_map - specializing KeyEqual with Lambda

I'd like to know if its possible to create a variable of type std::unordered_map like this:

std::unordered_map<std::weak_ptr<A>, B, std::hash<std::weak_ptr<A>,
[](const std::weak_ptr<A>& lhs, const std::weak_ptr<B>& rhs) -> bool { return lhs.lock() == rhs.lock(); }>

I expected it to work, because the KeyEqual template just expects a type that is implementing the () operator, but visual studio won't let me compile it, saying it's missing a type where the lambda stands.

Aucun commentaire:

Enregistrer un commentaire