Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion]simple fusion seq_size fails to compile
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-05-17 10:12:53


On 05/17/10 08:55, Pete Bartlett wrote:
>> The attached works; however, it just seems a lot of effort for such a
> simple task. >Anybody have a simpler way?
>
> Well, as you said the simpler way is to use the size function provided :-).
> Also your size implementation is somewhat unsatisfying in the sense that it
> uses empty which internally uses the library's size (meta)function.
[snip]
Well, as I said, I was trying to do "something like that". My actual
problem involves iterating over type list elements performing some
function. I guess fusion::transform would be appropriate; however, I
want to accummulate the results; so maybe I should be using
fusion::fold.

Anyway, I was just trying to figure a way to stop the terminal. I would
have thought:

   template<typename Seq>
   int f(Seq const&);

with termination caused by:

   int f(fusion::nil)

would solve the problem; however, pop_front(list<int>(1)) apparently
is not fusion::nil; hence, my problem.

Anyway, Tim Moore in a private email proposed the attached solution,
which seems simplest. BTW, I did try boost::fusion::iterator_range;
however, it didn't have next defined on it :(.

Thanks to Tim!

-regards,
Larry




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