
it compiled error! I redefined "channel_table_pr_view" like this, typedef multi_index_container< channel*, ordered_non_unique< key_from_key< BOOST_MULTI_INDEX_MEMBER(peer, int guid_), BOOST_MULTI_INDEX_MEMBER(channel, peer* pr_) >
channel_table_pr_view; and insert some element like this,
peer_table pt_;
const peer* pr1_ = *&(pt_.insert(peer(1)).first);
const peer* pr2_ = *&(pt_.insert(peer(2)).first);
... other 1000000
channel_table ct_;
ct.insert(channel(1, pr1_, 0));
ct.insert(channel(2, pr2_, 2));
ct.insert(channel(3, pr3_, 4));
... other 100000
nth_index
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 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://old.nabble.com/-multi_index--modify%7E%7E-tp29322711p29332372.html Sent from the Boost - Users mailing list archive at Nabble.com.