Edwin Rodríguez
Edwin Rodríguez

Reputation: 1257

specialize function for tuple parameter in C++11

I want to specialize a function for any tuple parameter. It should be something like this:

template <class T>
void f(T t) { ...code for default.. }

template <>
void f<std::tuple<...>> (std::tuple<...> t) } { ... code for tuples... };

It seems to be something related to template template parameters but I didn't find any example for my problem.

Upvotes: 0

Views: 169

Answers (1)

Piotr Skotnicki
Piotr Skotnicki

Reputation: 48457

You can't partially specialize a function; amongst available solutions, the best would be to introduce an overload instead:

template <typename T>
void f(T t) {}

template <typename... Ts>
void f(std::tuple<Ts...> t) {}

DEMO

Upvotes: 3

Related Questions