Boost logo

Boost Users :

Subject: [Boost-users] trouble with correct type definition of multi_index::nth_index
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-03-22 14:29:57


Hi,
 In the following code I am trying to get an handle to the index of a
multi_index container. The compiler says
"invalid initialization of reference of type
‘boost::multi_index::detail:..". Not sure why this is so. Since I
wasn't sure about the source of error I have pasted the full code (
sans declarations) is give below.

Thanks
sandeep

///-------------------------Full code ---------------------

template<typename Col1_t, typename Col2_t, typename Col3_t, typename Col4_t>
class TupleStore
{
  typedef tuple<Col1_t, Col2_t, Col3_t, Col4_t> tuple_t;
  typedef multi_index_container
    <
      tuple_t,
      indexed_by <
                   ordered_unique<tuple_member_extractor<tuple_t,0> >
>
> tuplestore_t;

   tuplestore_t m_tuplestore;
 public:

  template<int n>
  void lookup_key(Col1_t key) const
   {
     typedef typename tuplestore_t:: template nth_index<n>::type
tuplestore_index_t; ///compiler error here
     tuplestore_index_t& indexx = m_tuplestore.get<n>();

     }

};

int main()
{
  TupleStore<int,int,int,int> tstr;
  tstr.lookup_key<0>(5);
}


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