Boost logo

Boost Users :

Subject: [Boost-users] Insertion/Use of boost::multi_index
From: Ram (sourceopen_at_[hidden])
Date: 2016-09-19 01:54:04


Hi All ,

I have created a boost::multi_index container for my use and it compiles
successfully. I would like to add my pointer objects to it.
boost::multi_index does not seem to have an insert method defined which
just takes one arguement which is what I would like the container to store.
Maybe I didnt understand how boost::multi_index is meant to be used. Can
you please explain to me how to insert an object which I wish the store in
the container defined? How is it intended to be used? The container I
defined is ,

typedef boost::multi_index_ClassX<
  ClassX*,
  boost::multi_index::indexed_by<
boost::multi_index::hashed_unique<
    boost::multi_index::const_mem_fun<ParentOfClassX, Int64,
&ParentOfClassX::getKey1>,
                boost::multi_index::const_mem_fun<ParentOfClassX, Int64,
&ParentOfClassX::getKey2>,
>
>
> MultiIndexedClassX;

I would like to do an equivalent of,

MultiIndexedClassX sample;
ClassX a;

sample.insert(&a); <- Since I am interested in storing a *X and I would
like it to be indexed by various parameters of X.

Also please let me know how to,

1. Insert *X into the container
2. Look up by
           a) Value of ParentOfClassX::Key1
           b) Value of ParentOfClassX::Key2

Please also let me know if I have some basic understanding wrong since I am
getting confused a lot in trying to use boost::multi_index.

Thanks in advance,
Ram



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net