
It depends on what your container consists of. Ordered Index allows only insert. If it would support sequenced or random access policies you would have the push_back member. Regards, Ovanes On Tue, Sep 9, 2008 at 3:19 PM, Robert Jones <robertgbjones@gmail.com>wrote:
Still having a little teething trouble with multi_index_container. This code,
#include <string> #include <boost/multi_index_container.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/identity.hpp> #include <boost/multi_index/member.hpp>
using namespace boost; using namespace boost :: multi_index;
struct Employee { int id; std :: string name; };
bool operator < ( Employee const & l, Employee const & r ) { return l.id < r.id; }
int main( ) { typedef multi_index_container< Employee, indexed_by< ordered_unique<identity<Employee> >, ordered_non_unique<member<Employee, std :: string, & Employee :: name>
EmployeeSet;
Employee employees[ ] = { { 1, "Adam" }, { 2, "Craig" }, { 3, "Brian" }, { 4, "Dave" }, };
// EmployeeSet eSet( employees, employees + sizeof( employees ) / sizeof( Employee ) ); EmployeeSet eSet; std :: copy( employees, employees + sizeof( employees ) / sizeof( Employee ), std :: back_inserter( eSet ) );
return 0; }
Gives me an error stating there is no push_back method on the container.
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator.h:364: error: 'class boost::multi_index::multi_index_con tainer<Employee,
boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<Employee
, mpl_::na, mpl_::na>, boost::multi_index::ordered_non_unique<boost::multi_index::member<Employee, std::string, &Employ ee::name>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na , mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<Employee> >' has no member named 'push_back'
is there something I'm missing out?
Thanks, Rob. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users