Can the C++11 std::hash
type be used to hash function pointers? There is a hash
partial specialization defined as
template <typename T> struct hash<T*>;
but since function pointers are different from other pointer types in C++ (e.g. they can't be cast to void*
), I'm not sure whether it is safe to use it for types like int(*)()
or void(*)(int, int)
.
Is this permitted? Is there any specific wording in the new ISO spec that supports or refutes this?
Thanks!
std::unordered_map<void(*)(), std::string>
that could be an inverse map from strings to functions or something of that ilk. – Lazevoid*
. – Danielldaniella