Boost logo

Boost Users :

From: Hicham Mouline (hicham_at_[hidden])
Date: 2008-06-03 21:28:29

I submitted a post a few days ago
and I went to investigate on my own.

Having not reached a solution to speed up the compilation,
I looked again at the post and realized the code didn't compile
due to a wrong paste. Apologies (if anyone tried),

Anyways, here is the version that is too slow and runs out of mem during
on a P4 512Mb minimal redhat box with g++4.1
on core2duo 2Gb vista64 with intel 10.1, it compiles in 40s and runtime is

The point is to generate all template "curve" specializations for various
tmpl arguments
(constant, linear....) (cross product of 3 mpl sequences interpolator_types,
and integrator_types , each containing the possible tmpl type arguments 1, 2
and 3),
and insert the fully specialized templates curve<T1, T2, T3> in a mpl vector

"curve_types" to be used by make_variant_over.



#include <iostream>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/vector/vector0.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/size.hpp>
#include <boost/variant.hpp>

class constant {};
class linear {};
class polynomial {};
class cubic_spline {};
class simpson {};

template <typename inter, typename extra, typename integ> class curve {};

template <typename inter, typename extra, typename integ>
struct curve_metafunction {
        typedef curve<inter,extra,integ> type;

template<typename T> struct pair_with : boost::mpl::pair<T,boost::mpl::_>
template<typename pair> struct triple_with : curve_metafunction<typename
pair::first, typename pair::second, boost::mpl::_> {};

template<typename Sequence1,typename Sequence2>
struct sequence_product :

template<typename SequencePair, typename Sequence>
struct seq_seqpair_product :

template<typename Sequence1,typename Sequence2,typename Sequence3>
struct seq_product : seq_seqpair_product<
sequence_product<Sequence1,Sequence2>::type, Sequence3 >

typedef boost::mpl::vector<constant, linear, polynomial, cubic_spline>
typedef interpolator_types extrapolator_types;
typedef boost::mpl::vector<simpson> integrator_types;

typedef seq_product<interpolator_types,
extrapolator_types,integrator_types>::type curve_types;

struct type_printer {
 template <typename T> void operator()( T )
  std::cout<< typeid(T).name() <<std::endl;

int main()
        std::cout<< boost::mpl::size<curve_types>::type::value <<std::endl;
        boost::mpl::for_each<curve_types>( type_printer() );

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at