From: David Abrahams (dave_at_[hidden])
Date: 2005-02-28 09:16:02
Larry Evans <cppljevans_at_[hidden]> writes:
> On 02/28/2005 01:56 AM, David Abrahams wrote:
>> Larry Evans <cppljevans_at_[hidden]> writes:
>>> typedef range_c<int,0,3> types;
>>> typedef fold
>>> < types
>>> , empty_base
>>> , inherit< arg<2>, arg<1> >
>>> >::type tuple_type;
>>>I'd like to use for_each on tuple_type. For example:
>>> template<int i, typename Right>
>>> void operator()(inherit<integral_c<int,i>, Right>)const
>>>However, tuple_type is not a sequence; hence, for_each won't work.
>>>I could define the necessary specializations for mpl::begin, etc.,
>>>to make it a sequence, but I was wondering if there's any way
>>>or any plans to somehow automagically make fold or reverse_fold
>>>into a sequence so I could use for_each on it.
>> No. Since fold and reverse_fold are metafunctions (and therefore
>> class templates), they can't possibly be sequences (which are always
>> types). fold and reverse_fold don't even have to _return_ sequences.
> From my OP, the sentence:
> tuple_type is not a sequence;
> I thought would make it obvious that I didn't mean the metafunction, but
> the result of invokation of that metafunction.
> OTOH, I really should have said "make the result of a fold metafunction
> invokation into a sequence". Would that have been sufficient to make
> my meaning clear?
Not really. As I said, "fold and reverse_fold don't even have to
_return_ sequences." By that I mean that the result of invoking fold
might be, e.g. int.
>> I can't understand why you're not using Fusion, or at least trying
>> to fit into the Fusion framework, but I'm going to stop flogging
>> that horse now.
> IIUC, Fusion is in flux, based on the post:
> and mpl has an easy to use reference manual:
> OTOH, I haven't really looked at fusion, so maybe I should. It's
> just I've found mpl very good and I've gotten used to it; hence,
> I'm reluctant to change.
It's not a change. Fusion is a compatible layer on top of MPL.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk