Using Boost 1_33_1, I get an error message implying that my iterator is a constant iterator (because it will not allow me to get the result from find ()).
$ g++ bmi_iter_tst.cpp bmi_iter_tst.cpp: In function 'void tst(employee_set&)': bmi_iter_tst.cpp:32: error: invalid initialization of reference of type 'employee&' from expression of type 'const employee'
I know that I should not change any of the key values, and I do not, but I still need the non-constant acces sto to change other data in the elements of the container.
I know that I did it successfully elsewhere, I just can't figure out what this constant would do.
The code below is derived from the source example boost::multi_index
#include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> using boost::multi_index_container; using namespace boost::multi_index; struct employee { int id; int tst; employee(int id_):id(id_), tst(0){} }; struct id{}; typedef multi_index_container< employee, indexed_by< ordered_unique< tag<id>, BOOST_MULTI_INDEX_MEMBER(employee,int,id)> > > employee_set; void tst(employee_set& s) { employee_set::index_iterator<id>::type it = s.get<id>().find(11); employee& eref = *it; eref.tst++; }
source share