6
Mac OS Xでboost(1.53.0)でclang(CXX = 'clang ++ -std = C++ 11 -stdlib = libC++')を使用しています。std :: unordered_mapのキーとしてboost :: uuids :: uuid?
私はunordered_mapのキーとしてUUIDを使用したいが、次のエラー取得:
/usr/bin/../lib/c++/v1/type_traits:748:38: error: implicit instantiation of undefined template
'std::__1::hash<boost::uuids::uuid>'
: public integral_constant<bool, __is_empty(_Tp)> {};
^
/usr/bin/../lib/c++/v1/unordered_map:327:54: note: in instantiation of template class
'std::__1::is_empty<std::__1::hash<boost::uuids::uuid> >' requested here
template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
を...
/usr/bin/../lib/c++/v1/unordered_map:327:71: error: no member named 'value' in
'std::__1::is_empty<std::__1::hash<boost::uuids::uuid> >'
template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
~~~~~~~~~~~~~~~~~^
...
それは何ですか - バグBoostでは、これは私のC++ライブラリと互換性がありません?または私は何か間違っている?回避策はありますか?
+1 'std :: hash'の明示的な特殊化を提供する代わりに、型(例えば' uuid_hasher')を作成し、 'uuid_hasher :: operator()(uuid const&)'を実装することもできます。その型は 'unordered_map'の3番目のテンプレート引数になります – Praetorian
あなたのタイプのハッシュの特殊化の' operator() 'は' const'とマークする必要があります。 const以外のままにしておくと、コンパイルに失敗しました。 –