My best guesses are that committee either forgot about this use case or did not want to use concepts/requires to restrict the span
type to something that can be safely hashed(POD, no padding), or they did not want half solutions(waiting for reflection)...
If somebody is interested here is godbolt link with unhelpful error messages and code, but I presume my question is clear without any code.
#include <span>
#include <unordered_set>
#include <string_view>
int main() {
std::hash<std::string_view> h1;
std::hash<std::span<char>> h2; // error here
}
note: I know C++ std::
library is lacking in cases when it comes to hashing, e.g. it can not hash std::pair<int,int>
, but my question is in particular about the std::span
.