|
Boost : |
Subject: Re: [boost] [Fusion] fold takes state by cref. Why ?
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-04-10 19:42:58
On 4/10/2011 10:30 PM, Joel Falcou wrote:
> Why is the State passed by const reference ? I have a couple of use case (like using fold
> to access the element (i0,...,in) of a fusion
> sequence of pointer to ... pointer to T array) where I need to be able to discriminate the
> constness of the State to forward to
> the proper PFO overload of operator().
The type of 'State' may change on each iteration, so in general,
there really is no sense in having a mutable 'State'. It is
essentially pure FP. Having said that, there is no technical
reason why we can't allow a non-const state -it's just another
overload. It might also be useful for cases where the 'State'
type remains constant. I added such overloads. I'll commit as
soon as all tests pass.
Regards,
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk