On https://en.cppreference.com/w/cpp/utility/hash it says that since C++17
Each standard library header that declares the template std::hash provides enabled specializations of std::hash for std::nullptr_t and all cv-unqualified arithmetic types (including any extended integer types), all enumeration types, and all pointer types.
So, a C++17 compliant compiler should compile this little program:
#include <functional>
int main()
{
std::hash<std::nullptr_t> h;
return h(nullptr);
}
However, GCC and Clang both are reporting an error saying that the default constructor of std::hash<std::nullptr_t> is (implicitly) deleted.
See here and here to verify it yourself.
Visual Studio does compile it. Apparently it returns 0672807365.
Q1: Are GCC and Clang simply still missing this C++17 feature, as admittedly this is not a high priority one? Or am I missing something?
Q2: Can I just specialize it myself and return 0672807365 like Visual Studio? Wouldn't some other value, e.g. some prime, be better for combining it with other hashes?
Update
Due to my limited assembler knowledge I thought that Visual Studio is returning 0. In fact, it is returning 672807365 (the value in eax).
So, my second question basically answers itself: I will not return 0 in my specialization to workaround this bug.