2013-02-22 36 views
0

我在Key.h为什么没有被正确创建一对 - C++

typedef uint64_t KeyHash; 

,并在我的Finder类下面的声明,我必须声明如下一个C++地图:

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

因此,我正在尝试创建一个新的对。所述Foo对象具有两个字段,startKeyHashfoo_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

看起来你从Google带来的代码定义了一个uint64类型,并且在某处你不小心使用了该代码而不是uint64_t。请注意0​​丢失。

+0

这是真的......我应该从'uint64'投到'uint64_t'吗? – cybertextron 2013-02-22 18:45:04

+1

我会改正错字! – 2013-02-22 18:48:50

相关问题