-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
As far as I am aware (hope I am not mistaken), this should be valid C++ code.
#include <typeindex>
std::size_t test(int i) { return std::hash<int>()(i); }
From the C++ draft http://wg21.link/N4950:
In [unord.hash] 2:
Each header that declares the template hash provides enabled specializations of hash for nullptr_t and all
cv-unqualified arithmetic, enumeration, and pointer types
And in [type.index.synopsis] it is mentioned that the header <typeindex> also declares the template std::hash.
In my opinion the msvc STL has it correctly in this case and the code compiles correctly.
Both libc++ and libstdc++ currently do not work for this code snippet and reject it with implicit instantiation of undefined template 'std::hash<int>'.
I only checked it for <typeindex>, but this could affect more headers where std::hash is supposed to be defined as mentioned in cppreference.
Under the assumption that this is correct C++, would it be possible to fix these includes for the LLVM standard library?