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?
It looks like the current version of Boost defines BOOST_NO_VARIADIC_TEMPLATES if variadic templates are unavailable. This is provided by
boost/config.hpp; see here for config.hpp documentation.If variadic templates are unavailable, then you’ll probably have to simulate them with a bunch of overloads, as you said. The Boost.Preprocessor library can help here; it’s designed to automate all sorts of repetitive source code, including template overloads. You can search the Boost source trees for BOOST_NO_VARIADIC_TEMPLATES for examples on using it to simulate variadic templates.