I’m trying to get something like this to work:
// This method is wrong, won't work, need your help
template < template <typename T> class U >
void foo(U& u)
{
T& blah = *u.begin();
}
int main(int, char**)
{
vector<int> myVec(4, 10);
foo<vector<int> >(myVec); // This is how I want to call it, even better if I can leave the parameters out and just do foo(myVec);
return EXIT_SUCCESS;
}
Really what I want to do is avoid the following because it seems redundant:
template <typename T, typename U>
void foo(U& u)
{
T& blah = *u.begin();
}
int main(int, char**)
{
vector<int> myVec(4, 10);
foo<int, std::vector<int> >(myVec); // first int in parameters is redundant cause I already provide int as arg to vector
return EXIT_SUCCESS;
}
you can do :