mardi 31 mars 2015

Why s std::hash not specialised for std::reference_wrapper?

I thought it would have been, but I can't find this in my standard library implementation (gcc-4.8.2).


Why is std::hash not already specialised for std::reference_wrapper?



#pragma once
#include <functional>

namespace std
{
template<typename T>
struct hash<reference_wrapper<T>>
{
size_t operator()(const reference_wrapper<T>& r) const
{
return std::hash<T>()(r.get());
}
};
}

Aucun commentaire:

Enregistrer un commentaire