Robert Jones wrote:
Trying to multi_index_container I'm getting these compile errors. Apart from #include <string> and using namespace boost this lifted verbatim from the example documentation.
#include <string>
struct employee { int id; std::string name;
employee(int id,const std::string& name):id(id),name(name){}
bool operator<(const employee& e)const{return id
#include
#include #include #include using namespace boost;
// define a multiply indexed set with indices by id and name typedef multi_index_container< employee, indexed_by< // sort by employee::operator< ordered_unique
, // sort by less<string> on name ordered_non_unique
> employee_set;
My error is
multi.cpp:23: error: `indexed_by' was not declared in this scope multi.cpp:25: error: `ordered_unique' was not declared in this scope multi.cpp:25: error: `identity' was not declared in this scope multi.cpp:25: error: template argument 2 is invalid multi.cpp:25: error: expected unqualified-id before '>' token multi.cpp:25: error: expected `,' or `;' before '>' token
I'm using Boost 1.36 and gcc 3.4.4 (maybe this too old?). Can anyone tell me what I'm doing wrong?
Hi Rob,
The compiler is complaining because it can't find some of the types that
live in boost::multi_index. You can either add
using namespace boost::multi_index;
or qualify the types:
// define a multiply indexed set with indices by id and name
typedef boost::multi_index_container<
employee,
boost::multi_index::indexed_by<
// sort by employee::operator<
boost::multi_index::ordered_unique
employee_set;
David