In Execution.cpp
, I need to add unordered_map
. I used the following instruction:
#include <unordered_map>
std::unordered_map<StringRef, std::unordered_map<StringRef, struct IntRel>> BinaryRel;
but it invokes the following errors:
/usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of ‘struct std::hash<llvm::StringRef>’
struct hash;
/usr/include/c++/4.8/bits/hashtable_policy.h:1082:53: error: invalid use of incomplete type ‘struct std::hash<llvm::StringRef>’
using __ebo_h1 = _Hashtable_ebo_helper<1, _H1>;
You have to specialize std::hash
for your StringRef
type. For example:
#include <unordered_map>
struct StringRef {};
struct IntRel {};
namespace std {
template<>
struct hash<StringRef>
{
std::size_t operator()(const StringRef& s) const noexcept { return 0; }
};
}
int main()
{
std::unordered_map<StringRef, std::unordered_map<StringRef, struct IntRel>> BinaryRel;
}
Although I suggest better implementation of hashing function :D For this you can use one of existing specializations ( std::hash<std::string>
? if your StringRef
possibly contains std::string
object).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.