|
Boost : |
Subject: Re: [boost] [fusion] pop_back doesn't work on fwd sequences
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-11 21:08:01
On 8/10/2011 9:19 PM, Eric Niebler wrote:
> On 8/10/2011 3:06 PM, Joel de Guzman wrote:
>> On 8/11/2011 4:04 AM, Joel de Guzman wrote:
>>
>>> 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.
>>
>> Yep. It works like a charm. I have a fix. Now this works:
>>
>> {
>> list<int, int> l(1, 2);
>> std::cout << pop_back(l) << std::endl;
>> BOOST_TEST((pop_back(l) == make_list(1)));
>> }
>>
>> Now, indeed, the docs works as advertized.
>>
>> Thanks for your nudging, Eric. I truly appreciate it. You get my
>> neurons humming. Committed to trunk. I'd welcome a quick review
>> before I make this official.
>
> Very clever! Looks good to me.
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?
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk