Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile variadic templates conditionally?

Is there a macro that tells me whether or not my compiler supports variadic templates?

#ifdef VARIADIC_TEMPLATES_AVAILABLE

template<typename... Args> void coolstuff(Args&&... args);

#else

???

#endif

If they are not supported, I guess I would simulate them with a bunch of overloads. Any better ideas? Maybe there are preprocessor libraries that can ease the job?

like image 537
fredoverflow Avatar asked Jun 01 '10 17:06

fredoverflow


1 Answers

Maybe: #ifndef BOOST_NO_VARIADIC_TEMPLATES?


If variadic templates are not supported, you might think of using the boost tuple library:

template<typename Tuple> void coolstuff(Tuple&& args);

And:

coolstuff(boost::make_tuple(1, 2, 3));
like image 190
Karl von Moor Avatar answered Sep 25 '22 03:09

Karl von Moor