Subject: Re: [proto] vararg + fold
From: Eric Niebler (eric_at_[hidden])
Date: 2010-07-21 16:03:38
On 7/21/2010 3:51 PM, Christophe Henry wrote:
>> I was getting my A's and B's mixed up, and you're getting your A's and
>> trees mixed up. What you want is:
>> struct B
>> : or_<
>> when< comma< B, B >, fold_tree<..as before..> >
>> , when< A, mpl::vector1<A>() >
> Argh!!! *Grumble* *Grumble*
> This is exactly the first solution I came up with (and spent a while
> on :( ) but it didn't compile because in the 2nd "when", I used
> mpl::vector<A> instead of vector1<A> and I didn't manage to figure out
> what the compile error meant. I tried the vararg and my other solution
> out of despair.
This is a gotcha, no doubt. Sorry you got bit. Happens also with
fusion::vector, so beware of templates with high arities.
> Actually it is only almost the same solution, I actually had both
> "when" in different order but I suppose in this case it doesn't
> matter, right?
No, in this case it doesn't matter.
>> Incidentally, for the "state" parameter to fold_tree, you're using
>> mpl::vector<>(). That works by luck. Because of the template arity
>> thing, proto can't pull vector<> apart to check for nested transforms
>> (but there are none anyway). You'll better express your intent with
> Now I know it ;-)
> I think this would be a good point for a "tips and tricks section". I
> bet I won't be the last bitten by this one.
> Thanks a lot!
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com