Boost logo

Proto :

Subject: Re: [proto] vararg + fold
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2010-07-21 15:51:13


> 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.
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?

> 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
> mpl::vector0<>().

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!

Christophe


Proto list run by eric at boostpro.com