我正在尝试在Mac上编译项目,该项目最初是在linux上编写的。它在archlinux上运行顺利,但在mac上有很多错误。特别是,我对此错误消息非常困惑:In file included from /Users/STW/Documents/neuroblaze/nb/tagged_index/tagged_index.t.hpp:4:/Users/STW/Documents/neuroblaze/nb/tagged_index/tagged_index.hpp:425:26: error: implicit instantiation of undefined template 'std::hash<unsigned long>' ::std::hash<IndexType> hasher; ^这是相关的代码:(tagged_index.hpp)namespace std {/** * tagged_index can be hashed. Just forwards the hash to the contained type. * * @ingroup TaggedIndex */template <typename UniquenessTag, typename IndexType, typename ConstructorFunction>struct hash<tsb::tagged_index<UniquenessTag, IndexType, ConstructorFunction>> { using value_type = tsb::tagged_index<UniquenessTag, IndexType, ConstructorFunction>; ::std::hash<IndexType> hasher; size_t operator()(const value_type& l) const { return hasher(l); }};/** * tagged_offset can be hashed. Just forwards the hash to the contained type. * * @ingroup TaggedOffset */template <typename UniquenessTag, typename IndexType, typename ConstructorFunction>struct hash<tsb::tagged_offset<UniquenessTag, IndexType, ConstructorFunction>> { using value_type = tsb::tagged_offset<UniquenessTag, IndexType, ConstructorFunction>; ::std::hash<IndexType> hasher; size_t operator()(const value_type& l) const { return hasher(l); }};} // end namespace std我已经在此hpp文件中包含了功能。 最佳答案 您还包括“内存”吗?我刚刚发现Clang的标准库代码中可能有错误。它具有以下哈希定义:template <class _Tp> struct hash;这与__functional_base中的代码不同:template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;这可能会违反ODR,具体取决于_LIBCPP_TYPE_VIS_ONLY的定义方式。整数类型的hash 的所有特殊化都使用该符号,因此重新定义可能会使它们无效。我发现在记忆中包含功能比在记忆中包含功能要好。
10-08 04:16