Date: Tue, 31 Jan 2012 21:14:11 +0100
From: Abel Sinkovics
To: Larry Evans
Subject: Re: Template metaprogramming libraries
Hi Larry,
> Hi Abel,
>
> I thought maybe you'd be interested in using your
> library to solve the problem mentioned in the
>
> Boost::mpl vector product
>
> problem posed in this thread:
>
> http://article.gmane.org/gmane.comp.lib.boost.user/72558
>
> I'd be curious to see if it can be done.
> I hope it can.
Yes, it can. List comprehension can be implemented using the do notation
(http://www.haskell.org/tutorial/monads.html#sect9.2). Since Metamonad
supports the do notation, you can solve the problem the following way:
using boost::mpl::pair;
using mpllibs::metamonad::list_tag;
using mpllibs::metamonad::do_;
using mpllibs::metamonad::set;
using mpllibs::metamonad::do_return;
struct l1;
struct l2;
typedef
do_::apply<
set,
set,
do_return >
>::type
result;
Note that the list monad uses mpl::transform internally which doesn't
work with range_c, thus v2 has to be a sequence that is a copy of
range_c<....>
(http://www.boost.org/doc/libs/1_48_0/libs/mpl/doc/refmanual/range-c.html).
Regards,
Abel