私はグーグルスパースハッシュマップライブラリを扱っています。そして、次のクラス テンプレートがあります。
template <class Key, class T,
class HashFcn = std::tr1::hash<Key>,
class EqualKey = std::equal_to<Key>,
class Alloc = libc_allocator_with_realloc<std::pair<const Key, T> > >
class dense_hash_map {
.....
typedef dense_hashtable<std::pair<const Key, T>, Key, HashFcn, SelectKey,
SetKey, EqualKey, Alloc> ht;
.....
};
今、私は自分のクラスを次のように定義しました:
class my_hashmap_key_class {
private:
unsigned char *pData;
int data_length;
public:
// Constructors,Destructor,Getters & Setters
//equal comparison operator for this class
bool operator()(const hashmap_key_class &rObj1, const hashmap_key_class &rObj2) const;
//hashing operator for this class
size_t operator()(const hashmap_key_class &rObj) const;
};
今、メイン関数で次のように使用しながら、 my_hashmap_key_class
as a Key
、my_hashmap_key_class::operator()(const hashmap_key_class &rObj1, const hashmap_key_class &rObj2)
as EqualKey
、およびmy_hashmap_key_class::operator()(const hashmap_key_class &rObj)
asHashFcn
をパラメーターとしてクラスに渡したいと思います。dense_hash_map
main.cpp:
dense_hash_map<hashmap_key_class, int, ???????,???????> hmap;
クラスメンバー関数をテンプレートパラメータとして渡す適切な方法は何ですか??
私は次のように渡してみました:
dense_hash_map<hashmap_key_class, int, hashmap_key_class::operator(const hashmap_key_class &rObj1, const hashmap_key_class &rObj2),hashmap_key_class::operator()(const hashmap_key_class &rObj)> hmap;
しかし、演算子が検出されないため、コンパイルエラーが発生します。私が間違っているところを理解するのを手伝ってください。