I have a template for a function that accepts at least one parameter and performs some formatting on the rest:
template <typename T, typename... ARGS>
void foo(T first, ARGS&&... args)
{
// ...
}
I want it to do a different thing when the first parameter is of a specific type. I like the compiler to choose this particular version, where the rest of the variadic arguments are just ignored. So I tried template specialization:
template <>
void foo(const ICON* p)
{
// ...
}
or:
template <typename T, typename... ARGS>
void foo(const ICON* p, ARGS&&... args)
{
// ...
}
I also tried a non-templated overload, though it always picks the first version.
The caller code is supposed not to know about templates at all (legacy code, backwards-compatibility nonsense, etc.) So it relies on type deduction and calls like this:
MyClass fooMaker;
fooMaker.set("A", "B", 3.14, 42); // v1
fooMaker.set(pIcon); // v2 (special)