Can the C++11 std::hash type be used to hash function pointers? There is a hash partial specialization defined as
template
It's actually interesting... I bumped into this question while using MSVC++. What I'm trying to do is:
static std::unordered_map FunctionMap()
{
static std::unordered_map map;
return map;
}
with Fun a function pointer type.
During compilation, I get the following error:
error C2338: The C++ Standard doesn't provide a hash for this type.
....
_Kty=int (__thiscall Testje::* )(int,int)
In a previous attempt I attempted to cast the function pointer to void*, which isn't allowed and doesn't compile (see: https://isocpp.org/wiki/faq/pointers-to-members#cant-cvt-memfnptr-to-voidptr for details). The reason is that a void* is a data pointer, while a function pointer is a code pointer.
My conclusion so far is that it isn't allowed and it won't compile on MSVC++.