
hi,
i have a template function, the arguments of which i wish to have depend on a non-type int template argument:
template<int n> double f<n>( double arg0, double arg1, ..., double argn ) // ... is not
Hi, thanks for your answers,
Because I had tested just with :
1. static double sum(double d1, double d2, double d3)
{
return d1+d2+d3;
}
vs
2. static double sum(double d[3])
{
return d[0]+d[1]+d[2];
}
with calls to sum() in a tight loop.
I suspect boost::array is equivalent to 2.
was some 40% faster than 2 with advanced intel optimization.
Could you elaborate on the recursive generation?
Rds,
template
{ // for(int i=0; i
int main() { return x = f<3>( 1.0, 2.0, 3.0 ); }
BOOST_PP_REPEAT can't seem to do the job as the template argument n needs to be known at the preprocessing stage, which happens before the template instantiation stage ( this is part of compilation)
I don't understand why you want n to be passed explicitly. Can't it be deduced from the number of arguments (warning untested): #define SUM_IMPL(z, n, data) + arg ## n #define F_DEF(z, n, data) double f(BOOST_PP_ENUM_PARAMS_Z(z, n, double arg)) { return(0.0 BOOST_PP_REPEAT_ ## z(n, SUM_IMPL, ~)); } BOOST_PP_REPEAT(MAX_ARITY, F_DEF, ~) In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.14/1247 - Release Date: 1/28/2008 10:59 AM _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users