Boost logo

Boost Users :

Subject: Re: [Boost-users] Please help with metaprogramming question : termination of recursion
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-07-08 21:20:20


On 7/9/10 8:54 AM, Hartmut Kaiser wrote:
>>> You need to decide what function to call based on the _type_ of the
>>> fusion iterators:
>>> process_append(collection, begin, end, is_same<FusB, FusE>());
>>
>> There is no guarantee that the types will be the same _only_ when it is
>> the end. I'm pretty sure that's the case on a straightforward
>> implementation of 'cons', but what if the iterators are the same type when
>> the dereferenced element is the same type? At the very least, guarantee a
>> unique type for what 'end' is.
>>
>> Now if 'end' is a specific ending type, then I would hope to not need a
>> metafunction to figure it out, but could use some "cons end-of-iteration
>> type" easily obtainable from the cons, as an argument type of 'begin' in
>> an overloaded form of the function. That is, tag "end" types with a base
>> class for that purpose!
>>
>> Thanks for the fast reply! I thought I'd have to come back to it
>> tomorrow.
>
> Fusion iterators are unique regardless of the type of the value they
> dereference to. If you look at how the Fusion algorithms are implemented
> you'll see that there the same trick is utilized.

John, don't think in terms of Cons. Think in terms of Fusion iterators.
See the fusion for_each implementation for inspiration.

Regards,

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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net