I am looking for a way to provide a function that takes a templated (STL) container, but requires its elements to be of a certain type (e.g. int
).
These function calls should be VALID:
std::vector<int> Argument;
void foo( Argument );
std::list<int> Argument
void foo( Argument );
std::deque<int> Argument
void foo( Argument );
...etc
These function calls should be INVALID:
std::vector<float> Argument;
void foo( Argument );
std::list<double> Argument
void foo( Argument );
std::deque<char> Argument
void foo( Argument );
...etc
Is there a way to template "foo" such that containers of int
are accepted, but containers with different element types are not accepted ?
Best, Ben