Hello everybody.
I’m trying to compile on ROOT 6 a code that uses std::unordered_map, which, I admit, I’ve never used before.
Now, the lines that give me trouble are these:
enum class EProc {kPAIR = 0, kCOMP, kPHOT, kPFIS, kDRAY, kANNI, kBREM, kHADR, kMUNU, kDCAY, kLOSS, kMULS, kCKOV, kLABS, kRAYL};
const static std::unordered_map<EProc, const char*> mProcessIDToName;
When I try to compile the class, I get every kind of error, starting from
In file included from /usr/include/c++/5/unordered_map:47:
In file included from /usr/include/c++/5/bits/hashtable.h:35:
/usr/include/c++/5/bits/hashtable_policy.h:85:11: error: implicit instantiation of undefined template 'std::hash<EProc>'
noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
^
/usr/include/c++/5/type_traits:138:14: note: in instantiation of template class 'std::__detail::__is_noexcept_hash<EProc, std::hash<EProc> >' requested here
: public conditional<_B1::value, _B2, _B1>::type
^
/usr/include/c++/5/type_traits:148:39: note: in instantiation of template class
'std::__and_<std::__is_fast_hash<std::hash<EProc> >, std::__detail::__is_noexcept_hash<EProc, std::hash<EProc> > >' requested here
: public integral_constant<bool, !_Pp::value>
^
/usr/include/c++/5/bits/unordered_map.h:46:34: note: in instantiation of template class 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<EProc> >, std::__detail::__is_noexcept_hash<EProc,
std::hash<EProc> > > >' requested here
typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>>
^
/usr/include/c++/5/bits/unordered_map.h:100:15: note: in instantiation of default argument for '__umap_hashtable<EProc, const char *, std::hash<EProc>, std::equal_to<EProc>,
std::allocator<std::pair<const EProc, const char *> > >' required here
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/./MaterialManager.h:174:29: note: in instantiation of template class 'std::unordered_map<EProc, const char *, std::hash<EProc>, std::equal_to<EProc>, std::allocator<std::pair<const
EProc, const char *> > >' requested here
auto it = mProcessIDToName.find(process);
^
/usr/include/c++/5/bits/functional_hash.h:58:12: note: template is declared here
struct hash;
^
In file included from input_line_11:6:
In file included from ././MaterialManager.cxx:11:
In file included from /home/./MaterialManager.h:16:
In file included from /usr/include/c++/5/unordered_map:48:
/usr/include/c++/5/bits/unordered_map.h:522:7: error: multiple overloads of 'erase' instantiate to the same signature 'std::unordered_map<EProc, const char *, std::hash<EProc>, std::equal_to<EProc>,
std::allocator<std::pair<const EProc, const char *> > >::iterator (std::unordered_map<EProc, const char *, std::hash<EProc>,
std::equal_to<EProc>, std::allocator<std::pair<const EProc, const char *> > >::iterator)' (aka 'int (int)')
erase(iterator __position)
^
/home/./MaterialManager.h:174:29: note: in instantiation of template class 'std::unordered_map<EProc, const char *, std::hash<EProc>, std::equal_to<EProc>, std::allocator<std::pair<const
EProc, const char *> > >' requested here
auto it = mProcessIDToName.find(process);
^
/usr/include/c++/5/bits/unordered_map.h:517:7: note: previous declaration is here
erase(const_iterator __position)
^
I understood that the problem is related with using enum with unordered_map, but I really have no idea how to fix this.
Any help/tip would be much appreciated.
Thanks in advance!