All,

I am experimenting boost for some specific requirement.

The following code fails to retrieve the values. Could any one of you help me find out my mistake with the below code?

 

 

#include <boost/multi_index_container.hpp>

#include <boost/multi_index/ordered_index.hpp>

#include <boost/multi_index/member.hpp>

#include <boost/multi_index/composite_key.hpp>

struct Elem_entry

{

    unsigned int faceid;

    unsigned int node1;

    unsigned int node2;

    Elem_entry(const Elem_entry &obj){/*std::cout<<"copy const"<<std::endl;*/}

    Elem_entry():faceid(0),node1(0),node2(0){/*std::cout<<"defa const"<<std::endl;*/}

    Elem_entry(unsigned int faceid, unsigned int node1, unsigned int node2):

    faceid(faceid),node1(node1),node2(node2){}

};

 

typedef multi_index_container<

    Elem_entry,

    indexed_by<

    //non-unique as some  might have more than ids

    ordered_unique<

        composite_key<

            Elem_entry,

            member<Elem_entry,unsigned int,&Elem_entry::node1>,

            member<Elem_entry,unsigned int,&Elem_entry::node2>

            >

    >,

    ordered_unique<

    member<Elem_entry,unsigned int,&Elem_entry::faceid>

    >

   >

> elementbook;

 

 

int main()

{

      elementbook pb;

      Elem_entry fc1 = Elem_entry(1,1,2);

      pb.insert(fc1);

      Elem_entry fc2 = Elem_entry(2,2,3);

      pb.insert(fc2);

      Elem_entry fc3 = Elem_entry(3,3,1);

      pb.insert(fc3);

           

      int faceId = 0;

      elementbook::iterator it;

      //Below code not working     

      it = pb.find(boost::make_tuple(2,3));

      if(it != pb.end())

      {

            faceId = it->faceid;

            bool valid = true;

            valid = false;

      }

    for (elementbook::iterator iter = pb.begin(), i_end = pb.end(); iter != i_end;

        iter = pb.upper_bound(iter->faceid))

    {

        std::cout<<iter->faceid<<"\t"<<iter->node1<<"\t"<<iter->node2<<std::endl;

    }

}