
sorry, I have overseen it somehow... Probably too late already... That's
true, that array argument to a function is a pointer. Sorry.
I have tested the code with gcc under MacOS X, the function with arguments
as 3 doubles was NOT necesserely faster as the boost::array param. It might
be not worse implementing the macro based approach...
Here is my test app compiled with O3 optimization flags. (Below are the
timing on a Dual Core 2.4 processor machine with 4 gb ram)
//============================================================================
// Name : CppTest.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <numeric>
#include
AMDG
Hicham Mouline wrote:
After some though, here is more precisely what I'd like to have... I apologize that it is quite different from the initial problem:
template<int n> class Tree { static double sum(); // };
If the user instantiates tree<2>, he should get:
template<> class Tree<2> { static double sum(double d1, double d2); };
template<> class Tree<3> { static double sum(double d1, double d2, double d3); }; etc etc...
so that in user code, for e.g.:
double d= Tree<4>::sum(d1, d2, d3, d4);
should compile.
Is it possible for me to just define the template Tree for the n-case without the 2- and 3- specializations?
Ah. You still need the preprocessor, but you can rearrange the definitions slightly. (untested)
template<int N> struct TreeSumImpl;
#define TREE_SUM_DEF(z, n, data)\ template<>\ struct TreeSumImpl<n> {\ static double sum(BOOST_PP_ENUM_PARAMS_Z(z, n, double arg)) { ... }\ };
BOOST_PP_REPEAT(20, TREE_SUM_DEF, ~)
template<int N> struct Tree : TreeSumImpl<N> { // other code };
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users