Hi,

 

I have a function makeTree whose behavior depends on 3 different policies

typename T1

typename T2

int N

 

For performance reasons, I need to write the 2- and 3- specializations alongside the general N case. That is, the 2- and 3- default

instantiations generated from the N case by the compiler are not optimal.

 

As it is impossible to write function templates partial specializations, I encapsulate the

 

template< typename T1, typename T2, int N> void makeTree(Head<N>&, const T2&, const C&) ;

 

function in a class template

 

template< typename T1, typename T2, int N> class makeTree{

 void makeTree(Head<N>&, const T2&, const C&);

};

and write the partial specializations <T1,T2,2> and <T1,T2,3>.

 

 

Now, this makeTree function is quite large. It includes code that :

. doesn’t depend on any of the template arguments

. code that depends only T1

. code that depends only on T2

. code that depends only on N

. code that depends only on <T1,N>.

 

I am worried about code bloat, and the effect on overall performance of the actual code generated even if it is not run

(I noticed substantial effects depending on the size of object files and final shared library generated).

 

Besides this, I suppose it is a better design to have these segments of code put in template functions

with the right template arguments.

 

Is it MPL the library that I should look into for such work?

Perhaps nothing in Boost particularly facilitates this work, and std c++ templates are enough,

 

Thoughts, comments are appreciated,

 

Rds,