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-12 01:26:52


On 8/12/2011 9:24 AM, Joel de Guzman wrote:
> On 8/12/2011 9:08 AM, Eric Niebler wrote:
>
>> I wanted to test this, so I tried the following:
>>
>> using namespace boost::fusion;
>> auto vec = make_vector(1, 3.14, "hello");
>> auto push = push_back(vec, 42);
>> auto pop = pop_back(push);
>>
>> auto i1 = find<int>(pop);
>> auto i2 = find<double>(pop);
>>
>> assert(i1 != end(pop));
>> assert(i2 != end(pop));
>> assert(i1 != i2);
>>
>> It doesn't compile for me. I think it should. And I would hope none of
>> the asserts fire. Will that be the case?
>
> I think so. It's most probably a bug in the implementation. I'll go
> check it out.

It's fixed. It was a pop_back_iterator bug indeed. I reverted to the
original implementation but used advance<begin, size-1> instead of
prior. pop_back_iterator is an unwieldy hack and while it might be
fixable, I am not sure if its CT cost outweigh the CT cost of simply
using advance<begin, size-1>.

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