C++ Logo

std-discussion

Advanced search

C++17 std::hash disabled specializations

From: Edward Diener <eldlistmailingz_at_[hidden]>
Date: Wed, 15 Apr 2020 10:13:29 -0400
In C++17 if a std::hash specialization for a key is not provided and is
therefore considered a disabled specialization, is it a compiler error
if an unordered associate container is instantiated with that key ?

As an example:

struct MyStruct
{
int x;
long y;
MyStruct(int a, long b) : x(a), y(b) {}
};

/* No std::hash specialization is provided for MyStruct */

MyStruct my1(1,2);

std::unordered_set<MyStruct> oname;
oname.insert(my1);

Should the code cause a compilation error in C++17 and above ?

Received on 2020-04-15 09:16:31