
Dear all, I have a syntax like ((_1 >> &f1 >> &f2) || (_2 >> &f3) || (_3 >> &f4 >> &f5 >> &f6)) >> g for which I already have a small grammar which along with my context do their job fine. The above expression is to act like g(f2(f1(x)), f3(y), f6(f5(f4(z)))) once invoked with _1 == x, _2 == y, and _3 == z. I am currently trying to add a safety layer on top of that which can emit a compile-error -- at the appropriate corner of my code -- that can prevent pass of functions with wrong arities. For example, g above needs to be a ternary. Although my context will notice it if g is not a ternary and produce a meaningful error message, that's too late. My poor user needs to be informed right at the instantiation time. So, I thought I'm going to use transforms to get my grammar manage that. To that end, I thought the _state of my grammar needs to be an MPL pair of an mpl::int_ and an mpl::bool_. Below is my algorithm with some plain English explanation. Please would someone help me for I found it utterly formulate that in Proto. 1) when<terminal<_>, mpl::pair<mpl::int_<1>, mpl::true_> > -- so far, so easy. 2) When logical_or<Arity, Arity>, return summation of the two arities, paired with the logical and of success value in the two branches: mpl::pair < mpl::plus < typename _state(EmtnArity(_left))::first, typename _state(EmtnArity(_right))::first
, mpl::and_ < typename _state(EmtnArity(_left))::second, typename _state(EmtnArity(_right))::second
(This doesn't compile.) 3) When shift_right<Arity, Arity>, return mpl::int_<1> again, but, this time, paired with whether or not the right arity has been passed around logically anded with the success value so far: mpl::pair < mpl::int_<1>, mpl::and_ < typename _state(EmtnArity(_left))::second, is_callable_with_args(***)
And, I'm totally stuck in the use of is_callable_with_args! Any helps please? Feel free to pass a completely new design too. TIA, --Hossein