Boost logo

Boost :

Subject: Re: [boost] [fusion] pop_back doesn't work on fwd sequences
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-08-10 16:04:14


On 8/11/2011 3:40 AM, Eric Niebler wrote:
> On 8/10/2011 11:18 AM, Joel de Guzman wrote:
>> That example of yours [ push_back(nil(), 1) ] can also be made to
>> work by making 'nil' random-access. In essence, we should give all
>> sequences the highest potential traversal category that we can.
>
> OK, let's pick a different example:
>
> fusion::list<int> l(1);
> fusion::pop_back(fusion::push_back(l, 42));
>
> Although technically this works today, it's just a curiosity due to the
> way joint_view iterators work.

Interesting. I wouldn't think that would work. How did that work?

list is fwd, so according to your scheme
> so too would be push_back(l, 42), and so we couldn't legally call
> pop_back on it.

Yes, but that's as far as the view concepts can proceed. Anything more
will have to be a redesign of Fusion. Again, MPL's design does not
fit Fusion's because of the expensive runtime operations involved
with 'extensible-sequences'. So, unless you have a better suggestion,
that's the best I can offer ATM.

Hmmmm. now that I think about it, it is also possible to change the
implementation of pop_back to make it so that it would not need
to use 'prior'. The end iterator can be abstracted such that it
compares equal to i through next(i). I'll see if that works out.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://boost-spirit.com

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