|
Boost Users : |
From: Matt Calabrese (mcalabre_at_[hidden])
Date: 2004-03-09 05:47:45
I'm trying to create a metafunction which takes in a boost::mpl::vector
containing spirit parser types, and yields a vector of the original vector's
length plus one with each element representing the parser type made of the
recursive boost::spirit::alternative of all of the original parser types
from the corresponding element in the original vector and an epsilon_parser
at the end.
in other words, the metafunction should be able to take in:
(using boost::mpl and boost::spirit)
vector< chlit<>, strlit<>, range<> >
and yield a result:
vector< alternative< chlit<>, alternative< strlit<>, alternative< range<>,
epsilon_parser > > >,
alternative< strlit<>, alternative< range<>, epsilon_parser >
>,
alternative< range<>, epsilon_parser >,
epsilon_parser >
where empty is my own parser type, similar to epsilon_parser
I'm still new to metaprogramming and the mpl lambda facilities and I'm
having some trouble creating a metafunction which produces my desired type.
This is what I've come up with, though it doesn't work - I'm assuming
because of my second use of mpl::_1 in the nested template parameter of
mpl::front in mpl::push_front (which I'd like to have represent the current
state of the mpl::fold).
template< typename vector_t >
struct get_alternatives
{
typename mpl::fold_backward< vector_t,
mpl::vector< epsilon_parser >,
typename mpl::push_front< mpl::_1,
spirit::alternative< mpl::_2,
typename mpl::front< mpl::_1 >::type > >::type >::type type;
};
Any help is greatly appreciated. Thanks in advance.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net