|
Re: segmented fusion - a-ha!: msg#00061parsers.spirit.devel
Joel de Guzman wrote: Eric Niebler wrote: Even better. :-) And proto::binary_op can hold vector2<Left &, Right &>. Oh, this is almost too easy. Now, if for_each was an object (ala Fusion1), then segmented for_each Well, almost. You'd need to bind the unary function "f", somehow, like: for_each(segments(seq), bind(for_each, _1, f)) or something. But yeah, I get it. And something like fold that returns state will be a little trickier, but doable. Another interesting case is a transform_view on a segmented sequence. When you call segments() on such a transform view, you'll get back a sequence of transformed sequences. result_of::segments<TransformView>::type becomes transform_view< result_of::segments<TransformView::sequence_type>::type , apply_transform<TransformView::transform_type> > where apply_transform<> looks like: template<typename F> struct apply_transform { template<typename Sequence> struct result { typedef transform_view<Sequence &, F> type; }; apply_transform(F const &f) : f_(f) {} template<typename Sequence> transform_view<Sequence &, F> operator()(Sequence &seq) const { return transform_view<Sequence &, F>(seq, f_); } private: F const &f_; }; And is_segmented<TransformView> is simply is_segmented<TransformView::sequence_type>. Piece of cake. (Strike 1 for object algorithms, Dave?) If you can bind() arguments to fusion algorithm objects, then yes, algorithm objects would make this a little cleaner IMO. Effectively, each segment is unrolled for us by the mechanism Cool! :-) -- Eric Niebler Boost Consulting www.boost-consulting.com ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: segmented fusion - a-ha!: 00061, David Abrahams |
|---|---|
| Next by Date: | Re: segmented fusion - a-ha!: 00061, Eric Niebler |
| Previous by Thread: | Re: segmented fusion - a-ha!i: 00061, Eric Niebler |
| Next by Thread: | [spirit] Ternary Search Tree (TST) revisited: 00061, Joel de Guzman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |