Variable-length template argument lists in C++03?

Hi,
Is there a way that I can provide variable length template argument lists in
C++03 using boost? An example of what I want to achieve is below:
template< typename t1, typename t2, ..., typename tN >
void MyFunction( t1 param1, t2 param2, ..., tN paramN )
{
boost::tuple

Robert Dailey a écrit :
Hi,
Is there a way that I can provide variable length template argument lists in C++03 using boost? An example of what I want to achieve is below:
template< typename t1, typename t2, ..., typename tN > void MyFunction( t1 param1, t2 param2, ..., tN paramN ) { boost::tuple
myTuple; AnotherFunction( param1, param2, ..., paramN ); } Right now to do this I have to create several class specializations which gets very nasty. Help is appreciated. Thanks.
Using MPL::vector and inherit_from could help you.

AMDG Robert Dailey wrote:
Hi,
Is there a way that I can provide variable length template argument lists in C++03 using boost? An example of what I want to achieve is below:
template< typename t1, typename t2, ..., typename tN > void MyFunction( t1 param1, t2 param2, ..., tN paramN ) { boost::tuple
myTuple; AnotherFunction( param1, param2, ..., paramN ); } Right now to do this I have to create several class specializations which gets very nasty. Help is appreciated. Thanks.
The easiest way to do it is using the preprocessor:
// scratch.cpp
#ifndef BOOST_PP_IS_ITERATING
#include

on Thu Jul 10 2008, Steven Watanabe
AMDG
Robert Dailey wrote:
Hi,
Is there a way that I can provide variable length template argument lists in C++03 using boost? An example of what I want to achieve is below:
template< typename t1, typename t2, ..., typename tN > void MyFunction( t1 param1, t2 param2, ..., tN paramN ) { boost::tuple
myTuple; AnotherFunction( param1, param2, ..., paramN ); } Right now to do this I have to create several class specializations which gets very nasty. Help is appreciated. Thanks.
The easiest way to do it is using the preprocessor:
Yeah, more on this topic: http://www.boostpro.com/tmpbook/preprocessor.html -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (4)
-
David Abrahams
-
Joel Falcou
-
Robert Dailey
-
Steven Watanabe