I am attempting to use the Boost libraries for my first time. I am trying to
create a MultiIndex container of shared_ptrs to fairly complicated objects.
I've spent several days trying to figure this out, and I'm just spinning my
wheels, and I'd really appreciate some help. I'm afraid this message is
somewhat lengthy as I''ve tried to include appropriate detail.
I have a class of observations which I wish to sort by 9 elements. I have
overloaded operator< for this class, like so:
class Observation
{
private:
int x1;
int x2;
double x3;
...
double x9;
//other elements
public:
//Get Methods
int GetX1();
int GetX2();
double GetX3();
...
double GetX9;
//Overloaded operator<, == etc.
bool operator<(const Observation &rhs); //appropriate nontrivial logic
}
The code will dynamically create thousands of these things to be used in
many ways, so I've opted to use shared_ptr:
typedef boost::shared_ptr<Observation> SharedObservation;
I wish to view my collection of these various sorting criteria, or as linked
lists, so I'm trying to use multi_index_container. If I write:
typedef boost::multi_index_container<SharedObservation>
ObservationCollection;
and
void AnotherClass::functionUsingCollection(data)
{
SharedObservation temp(new Observation(data) );
//Check and see if I've got one already, before I do anything
master_collection.find(temp); //master collection is an object of type
ObservationCollection
}
However, there is no point to using multi_index_container if I sort by only
one index, so I've tried to expand out the index explicitly with an eye
towards adding more indexes as I develop the code, like so:
typedef
boost::multi_index_container ObservationCollection; //Add more indexing criteria later This does not compile on my Linux g++ (4. something bigger than 0) compiler.
After a truly horrendous spewage, the crux of the messages seem to be lines
like
usr/include/boost/multi_index/detail/ord_index_ops.hpp:65: error: no match
for call to ‘(const std::lessfuser::Observation) (fuser::Observation&,
const boost::shared_ptr