[英]Clang compiling error on 'std::hash<unsigned long>'
I am trying to compile a project on my mac, which is originally written on linux. 我正在尝试在Mac上编译项目,该项目最初是在linux上编写的。 It went smoothly on archlinux but has a lot of errors on mac.
它在archlinux上运行顺利,但在mac上有很多错误。 Especially, I'm very confused with this error message:
特别是,我对此错误消息非常困惑:
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;
^
And here is the relevant code:(tagged_index.hpp) 这是相关的代码:(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
I have included functional in this hpp file. 我已经在此hpp文件中包含了功能。
Are you also including "memory"? 您还包括“内存”吗? I just found what may be a bug in Clang's standard library code.
我刚刚发现Clang的标准库代码中可能有错误。
It has the following definition of hash: 它具有以下哈希定义:
template <class _Tp> struct hash;
This is not the same as the one in __functional_base: 这与__functional_base中的代码不同:
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
This may violate the ODR, depending on how _LIBCPP_TYPE_VIS_ONLY is defined. 这可能会违反ODR,具体取决于_LIBCPP_TYPE_VIS_ONLY的定义方式。 All the specializations for hash<> of integer types use that symbol, so possibly the redefinition is invalidating them.
整数类型的hash <>的所有特殊化都使用该符号,因此重定义可能会使它们无效。
I found that including functional after memory gets better results than including memory after functional. 我发现在记忆中包含功能比在记忆中包含功能要好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.