Я пытаюсь заставить что-то вроде этого работать:
// 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;
}
На самом деле я хочу избежать следующего, потому что это кажется избыточным:
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;
}