我有以下代码:
std::map<
const CosTransactions::otid_t,
std::pair<
CosTransactions::otid_t,
CosTransactions::Coordinator_ptr>,
otid_t_less> XID_Broker_impl::cache;编译上面的代码时,我得到一个错误,如下所示:
D:/Y24\usr\include/xmemory", line 144: error(483): function
"std::allocator<_Ty>::address(std::_Allocator_base<_Ty>::value_type
&) const [with _Ty=const CosTransactions::otid_t]" has already been
declared
detected during:
instantiation of class我正在使用HP-Nonstop C++编译器?当我删除map中key的"const“时,错误就消失了。这是否意味着我不能在map中使用"const key“?请在这个问题上帮我
发布于 2013-07-09 13:51:02
来自C++11§23.3.1类模板映射
For a map<Key,T> the key_type is Key and the value_type is pair <const Key,T>注意,这里的键类型根据定义是const,这意味着您不应该再次将键类型声明为const。
https://stackoverflow.com/questions/17540585
复制相似问题