包含类型的类型的模板函数重载

Template function overload for type containing a type

我正在尝试执行以下操作:

#include <iostream>
#include <vector>
#include <tuple>
#include <list>

template <typename T>
void f(T t) {
    std::cout << "1" << std::endl;
}

template <typename T, typename V>
void f(T<std::tuple<V>> t) {
    std::cout << "2" << std::endl;
}

int main() {
    f(std::list<double>{}); // should use first template
    f(std::vector<std::tuple<int>>{}); // should use second template
}

在 C++14 中执行此操作的最简单方法是什么?我以为我可以用这种方式进行模式匹配,但编译器不会。

模板参数T用作模板名称,因此应声明为template template parameter。例如

template <template <typename...> class T, typename V>
//        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void f(T<std::tuple<V>> t) {
    std::cout << "2" << std::endl;
}

LIVE