fw4spl
fwTools::BinaryCartesianProduct Struct Reference

Compute Cartesian Product of two set (type list) to generate all possible combinaison. More...

#include <Combinatory.hpp>

Classes

struct  apply
 

Detailed Description

Compute Cartesian Product of two set (type list) to generate all possible combinaison.

From two type list generate a new type list where all elemenent a combinaison of each set. For example :

using namespace boost::mpl;
typedef vector< char, short, long > Set1;
typedef vector< double, float > Set2;
typedef vector< vector< char,float>, vector<char, double>, vector< short,float>, vector<short, double>, vector<
long,float>, vector<long, double> > Wanted;
typedef apply< BinaryCartesianProduct, Set1, Set2 >::type Result;
BOOST_MPL_ASSERT_RELATION( size<Wanted>::value , == , size<Result>::value );
BOOST_MPL_ASSERT(( equal< front<Wanted> , front<Result> > ));
BOOST_MPL_ASSERT(( equal< at_c<Wanted,0> , at_c<Result,0> > ));
BOOST_MPL_ASSERT(( equal< at_c<Wanted,1> , at_c<Result,1> > ));
BOOST_MPL_ASSERT(( equal< at_c<Wanted,2> , at_c<Result,2> > ));

This operator can deal with empty set :

using namespace boost::mpl;
typedef vector<> emptySet;
typedef vector< char, short> Set1;
typedef vector< vector<char>, vector<short> >::type Wanted;
typedef apply< BinaryCartesianProduct, Set1, emptySet >::type Result;
BOOST_MPL_ASSERT_RELATION( size<Wanted>::value , == , size<Result>::value );
BOOST_MPL_ASSERT(( equal< front<Wanted> , front<Result> > ));
BOOST_MPL_ASSERT(( equal< at_c<Wanted,0> , at_c<Result,0> > ));
BOOST_MPL_ASSERT(( equal< at_c<Wanted,1> , at_c<Result,1> > ));

Definition at line 137 of file Combinatory.hpp.


The documentation for this struct was generated from the following file: