Boost logo

Boost Users :

Subject: Re: [Boost-users] Multi-Index: custom iterator
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2014-08-26 13:42:47


Sensei <senseiwa <at> gmail.com> writes:

>
> On 8/25/14, 9:14pm, Joaquin M Lopez Munoz wrote:
> > One easy way to get something roughly equivalent in many situations
> > to what you want is (warning, uncompiled):
> >
> > template<typename Tag>
> > typename boost::multi_index::index<DataStorage,Tag>::
> > index::const_iterator
> > myfind(const DataStorage& s,unsigned int v)
> > {
> > return s.template get<Tag>().find(v);
> > }
> >
> > ...
> >
> > auto it=myfind<byMSB>(storage,MSB(value128bits));
> >
> > myfind returns a different iterator type depending on the tag you
> > specify when calling it.
>
> Hi Joaquin, and thanks as usual!
>
> I am trying your solution with a member function, but I get the
> following error:

There was a typo in my uncompiled code. Rather than

  typename boost::multi_index::index<DataStorage,Tag>::index::const_iterator

one should write

  typename boost::multi_index::index<DataStorage,Tag>::type::const_iterator

Joaquín M López Muñoz
Telefónica


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