简体   繁体   English

在&#39;std :: hash上的Clang编译错误 <unsigned long> “

[英]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.

相关问题 铛错误:c ++ / 4.8 / bits / stl_iterator_base_types.h:227:29:错误:&#39;std :: iterator_traits中没有名为&#39;iterator_category&#39;的类型 <unsigned long> “ - clang error: c++/4.8/bits/stl_iterator_base_types.h:227:29: error: no type named 'iterator_category' in 'std::iterator_traits<unsigned long>' 麻烦用st编译std :: tuple - trouble compiling std::tuple with clang 是否可以保证std :: streampos是unsigned long long? - Is std::streampos guaranteed to be unsigned long long? 错误:&#39;类 std::unique_ptr <std::set<long unsigned int> &gt;&#39; 没有名为 &#39;size&#39; 的成员 - error: 'class std::unique_ptr<std::set<long unsigned int> >' has no member named 'size' 无符号长长溢出错误? - Unsigned long long overflow error? unsigned long long(10) 无法在 clang 和 gcc 上编译 - unsigned long long(10) fails to compile on clang and gcc Xcode Clang编译器中的unsigned long long意外行为 - unsigned long long unexpected behaviour in Xcode clang compiler g ++ 5中std :: unordered_set的类型不完整的编译错误,在clang ++中编译 - incomplete type for std::unordered_set compiling error in g++5, compiles in clang++ 使用memcpy,endian将unsigned long转换为std :: vector? - Conversion of unsigned long to std::vector with memcpy, endian? 对 &gt; `std::ostream::operator&lt;&lt;(unsigned long)' 的未定义引用 - undefined reference to > `std::ostream::operator<<(unsigned long)'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM