I am using Eclipse as the IDE to develop C++ programs.
I am declaring the following struct:
struct std::hash<SomeObject>;
However, I got the error message:
Symbol "hash" could not be resolved
Anyone can help me on this?
I am using Eclipse as the IDE to develop C++ programs.
I am declaring the following struct:
struct std::hash<SomeObject>;
However, I got the error message:
Symbol "hash" could not be resolved
Anyone can help me on this?
You may not be using C++11, which introduced the std::hash
type. You could add the flag for support (-std=c++11
) to your compiler options, see this post for more info.
Even if the symbol were found, that line would not compile as is.
If you are declaring an instance, you need to give it a name, otherwise it thinks you are forward-declaring a type. Otherwise, you can use typedef
or using
to name the type.
#include <functional>
// if you want to declare an instance
struct std::hash<SomeObject> aHashInstance;
// for types, one of:
typedef std::hash<SomeObject> MyHash;
using MyHash = std::hash<SomeObject>;