Boost logo

Boost :

Subject: Re: [boost] [ boost ] [ Trie ]
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2015-04-08 16:00:35


2015-04-08 22:49 GMT+03:00 Cosmin Boaca <boost.cosmin.boaca_at_[hidden]>:

> Hello,
>
> The main problem that appears is the following :
>
> In the implementation of the ++ operator I am doing something like
>
> iterator it = ++intrusive_set::s_iterator_to(*tnode)
> if (it != tnode->parent->children.end()) { /* code */ }
>
> In the implementation of the -- operator I need to do the reversed
> operation
>
> iterator it = --intrusive_set::s_iterator_to(*tnode)
> if (it != ??????) { /* code */ }
>
> I can't compare it with begin() because the comparison should work for the
> begin node, but fail for a node that is somehow before begin(), like end()
> is past the last element. I don't know how to achieve this. I have tried
> casting the iterator to reverse_iterator but it didn't help me.

How about

iterator it = intrusive_set::s_iterator_to(*tnode)
if (it != tnode->parent->children.begin()) { --it; /* code */ }

-- 
Best regards,
Antony Polukhin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk