And what is the problem with the same key appearing more than once in case the index is (ordered/hashed)_non_unique index?

 

 

From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Uthpal Urubail
Sent: Thursday, June 04, 2015 12:22 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] boost multi_index_container with composite_key iterator

 

Experts,

Is there a better approach to iterator over boost multiindex composite key?

The issue with the below approach is, the same key is appearing multiple times.

 

       typedef multi_index_container loadTable_Def;

       loadTable_Def pb;

      

//!

       for(loadTable_Def::iterator i=pb.begin(),i_end=pb.end();i!=i_end; )

       {

        // Get the range of the current key

        loadTable_Def::iterator iter_next=pb.upper_bound(pb.key_extractor()(*i));

              do

              {

                     loadTable_Def::iterator it1,it2;

                     boost::tie(it1,it2) = pb.equal_range(boost::make_tuple(<passing multiple key >));

                     while(it1 != it2)

                     {

                           //std::cout<<”print values”<<" ,";

                           ++it1;

                     }

              }

              while(++i!=iter_next);

       }

Regards,

UJ

Read More