Hello,
1) I now managed to produce the cartesian product of 3 mpl
sequences applying my custom metafunction to the resulting triplets,
however it takes like 40seconds to compile. I doubt this is the optimal
way to write the cartesian product metafunction. (code compiles as-is,
below)
2) By the way, cartesian product hasn't been deemed generic enough to be
included
in the MPL?
3) what would be the equivalent of mpl::pair for 3 or more? boost::tuple or
boost::variant?
Your help is very appreciated, thank you,
#include <iostream>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
template class curve {};
template
struct curve_metafunction {
typedef curve type;
};
template<typename T> struct pair_with : boost::mpl::pair
{};
template<typename pair> struct triple_with :
curve_metafunction < typename pair::first,
typename pair::second,
boost::mpl::_
>
{};
template
struct sequence_product :
boost::mpl::fold<
Sequence1,
boost::mpl::vector0<>,
boost::mpl::joint_view<
boost::mpl::_1,
boost::mpl::transform<
Sequence2,
pair_withboost::mpl::_2
>
>
{};
template
struct seq_seqpair_product :
boost::mpl::fold<
SequencePair,
boost::mpl::vector0<>,
boost::mpl::joint_view<
boost::mpl::_1,
boost::mpl::transform<
Sequence,
triple_withboost::mpl::_2
>
>
{};
template
struct seq_product : seq_seqpair_product<
sequence_product::type, Sequence3 >
{};
typedef boost::mpl::vector
interpolator_types;
typedef interpolator_types extrapolator_types;
typedef boost::mpl::vector<simpson> integrator_types;
typedef seq_product::type curve_types;
struct type_printer {
template <typename T> void operator()( T )
{
std::cout<< typeid(T).name() <::type::value <( type_printer() );
}
-----Original Message-----
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe
Sent: 31 May 2008 20:51
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] variant<> number of template arguments
AMDG
Hicham Mouline wrote:
It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES.
This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and
win-i386-vs2005- boost-1.35.0)
<snip>
If I add type19, making the mpc vector have 21 types, compilation fails...
The limit of variant and the limit of mpl::vector happen to be the same.
For more types, try using the numbered form of mpl vector which can
handle up to 50 arguments.
#include
typedef boost::mpl::vector21<...> types;
In Christ,
Steven Watanabe