C++ Logo


Advanced search

Subject: C++17 std::hash disabled specializations
From: Edward Diener (eldlistmailingz_at_[hidden])
Date: 2020-04-15 09:13:29

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;

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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups