Having done a brief search on the following error code from GCC, a number of hits show questions asking for help for this problem, but nothing much concrete turns up:
error: explicit specialization of non-template 'std::hash'
It looks like std::hash is indeed a template, so the error is not clear on what the problem is. Sample code to generate the message is below. The GCC option, -std=c++0x, compiles the code just fine. The problem being that I have an older compiler that does not support C++11 on one machine, so some clarification on why this does not compile would be useful.
An alternative might be to use inheritance instead of specialization, and if that is the only solution, then that would be nice to know, also.
#include <functional>
struct test
{
int n;
};
namespace std
{
template<>
struct hash<test>
{
};
}
The problem is that
std::hash, and the unordered containers that use it, didn’t exist before C++11. If you need to use a compiler that only understands C++98, then you can’t use them.Similar containers are available in TR1 and Boost.