I do not understand why my compiler will not accept the code below
#include <unordered_set>
#include <unordered_map>
template<class T>
using M = std::unordered_set<T>;
template<class T>
using D = M<T>;
template<class T>
using DM = std::unordered_map < typename M<T>::const_iterator
, typename D<T>::const_iterator >;
int main(int argc, char ** argv)
{
D<int> d;
M<int> m;
DM<int> dm;
}
Compiler command
clang++ -std=c++14 test.cpp -o test
Excerpt from compiler error message
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.1/../../../../include/c++/5.3.1/bits/hashtable_policy.h:85:11: error:
implicit instantiation of undefined template
'std::hash<std::__detail::_Node_const_iterator<int, true, false> >'
noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
Why is it not allowed to use typename M<T>::const_iteratoras a key in std::unordered_map?
source
share