Re: Boost.Intrusive: getting the next element

Phil Endecott via Boost-users <[email protected]>
Newsgroups gmane.comp.lib.boost.user
Message-ID <[email protected]>
Gonzalo Arana wrote:
> Given an element (contained in a list), how may I get the next one, without
> requiring access to the list itself?
>
> I only found this way to get the next element:
>
> auto iterator = list.iterator_to(value);
> ++iterator;
> return *iterator;
>
> But it requires access to the list itself.


Use s_iterator_to, which is a static member of the list type:


list_t list;
..
auto iterator = list_t::s_iterator_to(value);
++iterator;
return *iterator;


Regards, Phil.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.