|
Boost : |
Subject: Re: [boost] [fusion] segmented fusion 2.0
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-11 21:46:04
On 8/11/2011 5:58 PM, Joel de Guzman wrote:
> On 8/12/2011 8:37 AM, Eric Niebler wrote:
>> That's what I referred to by "baking it in". I imagine that all the ext_
>> directories go away, and segmentation support just becomes a native part
>> of Fusion. These things would need to change:
>>
>> - We find a new home for segmented_iterator.hpp et. al.
>> - Sequence intrinsics (begin, end, size, empty) have meaningful default
>> implementations for segmented data structures.
>> - As many algorithms as possible should dispatch to segmented flavors
>> when appropriate. E.g., ext_/fold_s.hpp just gets merged into fold.hpp.
>> - Fusion containers and views that are segmented (joint_view) advertize
>> themselves as such, and the rest of their implementation goes away.
>
> Sounds like a plan. If you have some initial sketch/notes that
> you can share, I'd love to get in the same page with you and share
> some effort to get this going asap.
Here's my thinking:
1)
support/ext_/is_segmented.hpp => support/
sequence/intrinsic/ext_/segments.hpp => sequence/intrinsic/
sequence/intrinsic/ext_/size_s.hpp => sequence/intrinsic/detail/
view/ext_/segmented_iterator.hpp => iterator/
view/ext_/segmented_iterator_range.hpp => view/iterator_range/detail/
view/ext_/segmented_begin.hpp => sequence/intrinsic/detail/
view/ext_/segmented_end.hpp => sequence/intrinsic/detail/
view/ext_/segmented_fold_until.hpp => support/
Various supporting implementation details make corresponding moves.
container/ext_/tree.hpp becomes part of the test suite. It is poorly
designed and doesn't deserve to be part of Fusion proper.
2) begin, end, size and empty dispatch to their segmented
implementations by default.
3) The existing segmented algorithms (find_s, find_if_s, fold_s,
for_each_s) just get merged with their non-segmented equivalents.
4) Wait for the dust to settle. Assuming all is looking good, try making
joint_view segmented.
5) Use segmented_fold_until to write segmented flavors of as many
algorithms as possible.
I can do 1-3. 5 can be a team effort and can begin as soon as everything
has found its rightful place.
A word about segmented_fold_until. You call it with a hierarchical data
structure, an initial state and a function. It walks the hierarchical
structure and calls a function with each non-segmented range, the
current state, and the "context". The context is actually the path
through the tree to reach the current leaf range. You can pass it to
make_segmented_iterator to (duh!) create a segmented iterator. The
function that you pass to segmented_fold_until must wrap its returned
object in a fusion::result, which contains a compile-time boolean:
continue the fold or break. The returned object is the new state.
-- 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