C boost :: bimap insert()方法不起作用
C++ boost::bimap insert() method not working
我试图将数据插入boost :: bimap,但给出了一个错误。
typedef boost::bimap<std::string, std::string> bimap_type;
bimap_type _obs_ids;
void store_domains_obs_ids(const std::string & name, const std::string & obs_id) const
{
_obs_ids.insert(bimap_type::value_type(name, obs_id));
}
错误::
no instance of overloaded function "boost:thimaps::bimap<KeyTypeA, KeyTypeB, AP1, AP2, AP3>::insert [with KeyTypeA= std::string, KeyTypelhstd::string, AP1=boost::mpl::na, AP2= boost::mpl::na, AP3= boost:mph:na]" matches the argument list and object (the object has type qualifiers that prevent a match) argument types are: (boostthimapsuelation::mutant_relation<boostthimaps::tags::tagged<const std::string, boost:thimapsuelation::member_athleft>, boost::bimaps::tags::tagged<const std::string, boostthimapsuelation::member_athright>, boost::mpl::na, false>) object type is: const ipm::config::bimap_type
您必须从成员函数签名中删除 const
:
void store_domains_obs_ids(const std::string & name, const
std::string & obs_id) const
{}
应该是
void store_domains_obs_ids(const std::string & name, const
std::string & obs_id)
{}
内部 const 成员函数, _obs_ids
被视为const对象,对于const对象,您只能调用 const 函数成员。因为insert
修改了bimap
实例,因此您只能从非const函数调用此函数。
相关文章:
- 基本加密和解密方法不起作用 C++ 11.
- 结构/方法不起作用
- 将字符数组设置为彼此相等的方法不起作用
- ConvertToReferencePoint 方法不起作用,获取作业参数的 NULL (HyperV 2016)
- 为什么方法不起作用?
- C boost :: bimap insert()方法不起作用
- 为什么我的将向量保存到文件然后再次读出的方法不起作用?
- 为什么这种交换方法不起作用
- Qt. 方法显示文本() 如果我在 QStyledItemDelegate 中定义了 paint() 方法不起作用
- 非递归二进制树插入()方法不起作用
- C++中的Friend方法不起作用
- 为什么这种删除文件夹中文件的方法不起作用?
- 二叉树递归插入方法不起作用
- CGI POST方法不起作用
- 为什么我的 pow 方法不起作用?
- 类方法不起作用
- 使用ctypes从Python调用C++方法不起作用
- C++虚拟方法不起作用
- 为什么用double&&初始化对象方法不起作用?
- 使用虚拟重写基类方法不起作用