Re: [Boost-users] [fusion]simple fusion seq_size fails to compile

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. In fact I think size has to be implemented as a "core" function (i.e. not built up from other publically available functions) because it is implementation is necessarily quite different for different types of fusion sequence (e.g. array and an MPL sequence). Not an expert, Pete

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
On 05/17/10 08:55, Pete Bartlett wrote: 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
participants (2)
-
Larry Evans
-
Pete Bartlett