0

私は次の宣言を持っていますKey.h

typedef uint64_t KeyHash;

私のFinderクラスでは、C++次のように宣言されたマップがあります。

std::map<std::pair<uint64_t, KeyHash>, Foo> table;

したがって、私は新しいペアを作成しようとしています。オブジェクトには とのFoo2 つのフィールドがstartKeyHashありfoo_id、どちらもタイプはuint64_t:

std::pair<uint64_t, KeyHash> key (foo.foo_id,
                                  foo.start_key_hash());
table[key] = tablet;

関数uint64_t Foo:start_key_hash()は を返しますstartKeyHash。ただし、コードをコンパイルすると、次のエラーが発生します。

error: no matching function for call to ‘std::pair<long unsigned int, long unsigned int>::pair(<unresolved overloaded function type>, google::protobuf::uint64)’
/usr/lib/gcc/x86_64-redhat-`linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:111: note:
 candidates are: std::pair<_T1, _T2>::pair(_U1&&, _Arg0&&, _Args&& ...) [with _U1 =
 google::protobuf::uint64, _Args = , _T1 = long unsigned int, _T2 = long unsigned int]`

何かご意見は?

4

1 に答える 1

4

Google から持ち込んでいるコードは型を定義しているように見えますがuint64、どこかで誤ってuint64_t. がないことに注意してください_t

于 2013-02-22T18:43:16.060 に答える