に渡されるカスタム C++ 比較関数を実装しようとしていstd::map
ます。map
APIの指示に従って、以下を実装しました。
35 typedef std::pair<uint64_t, KeyHash> TabletKey;
36
37 class CmpTabletKey {
38 public:
39 bool operator()(const TabletKey& key1, const TabletKey& key2) const {
40 if (!(key1.first < key2.first)) {
41 return false;
42 }
43 if (!(key2.first < key1.first)) {
44 return false;
45 }
46
47 return true;
48 }
49 };
map
がプロパティであるクラス内には、次のものがあります。
55 class ObjectFinder {
56 public:
57 class TableConfigFetcher; // forward declaration, see full declaration below
58 class CmpTabletKey;
// .. more code here
private:
97 std::map<TabletKey, ProtoBuf::Tablets::Tablet, CmpTabletKey> tableMap;
}
そして、次のエラーが発生します。
/home/ribeiro.phillipe/ramcloud/src/ObjectFinder.h:97: instantiated from here
/usr/lib/gcc/x86_64-redhatlinux/4.4.6/../../../../include/c++/4.4.6/bits/stl_tree.h:453:
error: incomplete type ‘RAMCloud::ObjectFinder::CmpTabletKey’ not allowed
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/map:60,
なぜそれが起こっているのかわかりません。また、私はstd::less
実装をあまり使用することはありません