Hello,
I submitted a post a few days ago
http://lists.boost.org/boost-users/2008/06/36852.php
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
compilation
on a P4 512Mb minimal redhat box with g++4.1
while,
on core2duo 2Gb vista64 with intel 10.1, it compiles in 40s and runtime is
correct.
The point is to generate all template "curve" specializations for various
tmpl arguments
(constant, linear....) (cross product of 3 mpl sequences interpolator_types,
extrapolator_types
and integrator_types , each containing the possible tmpl type arguments 1, 2
and 3),
and insert the fully specialized templates curve in a mpl vector
"curve_types" to be used by make_variant_over.
Regards,
--------------------
#include <iostream>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class constant {};
class linear {};
class polynomial {};
class cubic_spline {};
class simpson {};
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 {};
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() );
}