"Eric Niebler" schrieb im Newsbeitrag news:<4A8BB56F.7050706@boostpro.com>...
Steven Watanabe wrote:
christophe henry wrote:
I am trying to build a mpl::vector from an expression like
(string(),ClassA(),ClassB())
To get a mpl::vector
Is there a way to do this or I should give up the idea?
Does fold_tree help?
It does.
*snip*
Ah It see. Thanks a lot, I think I got the idea.
I just have a concern with:
template<class T> struct is_my : mpl::false_ {};
template<> struct is_mystd::string : mpl::true_ {};
template<> struct is_my<ClassA> : mpl::true_ {};
template<> struct is_my<ClassB> : mpl::true_ {};
As it forces extra declarations which not everybody is willing to make. But based on the same fold idea I can allow something like:
attributes_ << int() << std::map
// Put all other terminals at the head of the
// list that we're building in the "state" parameter
, proto::when<
proto::terminalproto::_
, fusion::cons
// For left-shift operations, first fold the right
// child to a list using the current state. Use
// the result as the state parameter when folding
// the left child to a list.
, proto::when<
proto::shift_left
{};
I then just have to invert the order again as it gets reversed (ok a few seconds more to compile...):
boost::mpl::copy