Question

I am making an unordered map: whose key consists of three characters and value is integer.

Here is the code:

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;
}

but when I compile the code, I get this error

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’

Plese help me what I am doing wrong?

Was it helpful?

Solution

I'm guessing the problem is with your key_equal, where you make a binary function taking three arguments. A binary function is a function that takes two arguments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top