Boost logo

Boost :

Subject: [boost] [multi_index_container] Compiling the examples
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-09-09 06:20:37


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<e.id;}
};

#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;

// define a multiply indexed set with indices by id and name
typedef multi_index_container<
  employee,
  indexed_by<
    // sort by employee::operator<
    ordered_unique<identity<employee> >,

    // sort by less<string> on name
    ordered_non_unique<member<employee,std::string,&employee::name> >
>
> 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?

Thanks, Rob.

-- 
ACCU - Professionalism in programming - http://www.accu.org

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk