In C++11/C++14,
template <
typename T ,
template <typename...> class Container_t
>
void MyFunc(Container_t<T> &data) { ... }
template <typename T>
void MyFunc2( T v ) { ... }
int main()
{
std::vector<char> v;
MyFunc<char, std::vector>(v); // OK
MyFunc(v); // error
int i;
MyFunc2<int>(i); // OK
MyFunc2(i); // OK
}
I get an error with MyFunc(v)
.
Is it possible in any way to let the compiler find out the type of the container passed to the variadic template function? I can see no problems in finding it out, as with a normal types in normal templates.
If I need to change the type of v, do I have to fix all the calls to MyFunc?
Compiler: Microsoft Visual C++ 2015 (v140)