Boost logo

Boost Users :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2003-07-11 12:14:18


Brian Simpson wrote:
> It gets me to the next (apparent) obstacle, which is that I need to define
a
> variant using the types in the derived sequence (the second_types, to be
> specific).

Are we talking about 'boost::variant' here? Because the latter accepts
MPL-sequence template arguments directly - you just pass a sequence to it,
and
that's all.

> I'm putting together another post for that one.
>
> BTW, would it be possible, using mpl::fold, to get Borland5 to do this?
I
> know that it won't support mpl::lambda, and I'd like my code to compile on
> Borland5 in addition to gcc3.2.2 . I'll be looking into it, but if you
can
> alert me that it's not possible, that would save me time :).

All MPL algorithms that take lambda expressions can also take _metafunction
classes_, so if lambda is unavailable/too complicated, you can always write
a
standalone auxiliary metafunction class that does what you want and just
pass
it to the algorithm, e.g.

    struct do_something
    {
        template< typename State, typename T > struct apply
        {
            // ...
            typedef ... type;
        };
    };

    // ...
    typedef mpl::fold< seq, do_something >::type result;

Just like you would do it in STL without Boost.Lambda :).

>
> I'm sure I'll be asking for more details later, but for now the
> documentation is coming through for me.

Good!

Aleksey


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