I'm writing a function template like this:
template <class T>
class MyClass() {}
template <typename A, typename B>
auto func(A<B>& data) {
return MyClass<B>();
}
Run Code Online (Sandbox Code Playgroud)
So I can using the function like this:
vector<int> vi; auto a = func(vi);
vector<string> vs; auto b = func(vs);
list<int> li; auto c = func(li);
list<string> ls; auto d = func(ls);
Run Code Online (Sandbox Code Playgroud)
But obviously it's not allowed. How should I write a template to reach my goal?