
isjk escribió:
hi,
now, I have two structures like this,
[...]
typedef multi_index_container< const channel*, ordered_non_unique< key_from_key< BOOST_MULTI_INDEX_MEMBER(peer, const int, guid_), BOOST_MULTI_INDEX_MEMBER(channel, const peer*, pr_) > >
channel_table_pr_view;
[...]
channel_table_pr_view::iterator ictpv = ctpv.find(guid_); if (ictpv != ctpv.end()) { ctpv.modify(ictpv, _Modify_prop()); // right or not? }
struct _Modify_prop{ void operator()(channel& cl_) { cl_.prop = rand(); } };
This is not correct: _Modify_prop is passed a reference to the element of channel_table_pr_view, which is a const channel*, so the right signature for _Modify_prop::operator() is struct _Modify_prop{ void operator()(const channel*& pcl_); }; Due to the const qualifier you won't be able to do the modification, so consider redefining channel_table_pr_view as holding pointers to non-const objects: typedef multi_index_container< channel*, ordered_non_unique< ...
channel_table_pr_view;
and making the necessary adjustments. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo