Hello,
I need metafunction cross_product, which
should
transform 2 sequences to a sequence
of pairs.
Example:
typedef list<int, char> l1;
typedef list<int *, char *> l2;
typedef cross_product<l1, l2>::type
c;
typedef list<
pair<int, int *>,
pair<int, char *>,
pair<char, int *>,
pair<char, char *>
> e;
BOOST_MPL_ASSERT((equal<c, e>));
The best definition I came up with is
the
following:
template <class T, class R>
struct product : transform<R, pair<T,
_1> >
{
};
template <class R1, class R2>
struct cross_product :
fold<
typename
transform<R1, product<_1, R2> >::type,
list<>,
joint_view<_1,
_2>
>
{
};
Is there a better way to do it? How
can I get rid of
'struct product' and implement it as
one metafunction?
Regards,
Roman Perepelitsa
Deutsche Bank Moscow
+7 (495) 660-74-08
---
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.