我正在制作一个无序映射:其键由三个字符组成,值是整数。
这是代码:
namespace G {
typedef std::tuple< char, char, char> key_t;
struct key_hash : public std::unary_function<key_t, std::size_t>
{
std::size_t operator()(const key_t& k) const
{
return std::get<0>(k) ^ std::get<1>(k) ^ std::get<2>(k);
}
};
struct key_equal : public std::binary_function<key_t, key_t, key_t, bool>
{
bool operator()(const key_t& v0, const key_t& v1, const key_t& v2) const
{
return (
std::get<0>(v0) == std::get<0>(v1) &&
std::get<1>(v0) == std::get<1>(v1) &&
std::get<2>(v0) == std::get<2>(v1)
);
}
};
struct IndexGuide
{
int index;
};
typedef std::unordered_map<const key_t,IndexGuide,key_hash,key_equal> GuideDouble;
}
但是当我编译代码时,我得到了这个错误
In file included from StateTableGenerator.cpp:3:0:
StateTables.h:72:75: error: wrong number of template arguments (5, should be 3)
/usr/include/c++/4.6/bits/stl_function.h:115:12: error: provided for ‘template<class _Arg1, class _Arg2, class _Result> struct std::binary_function’
请帮助我我做错了什么?