A bit of a simple question, I think.
Vectors and lists have push and pop functions, and, more importantly, you can repeat:
for ( auto value : items ) ...
Nonetheless,
std :: vector and std :: list do not have a common class. Therefore, the question arises: how to write a function that will take one (or, really, something else that corresponds to the implementation)?
std::list<int> a; std::vector<int> b; DoSomething(a); DoSomething(b);
I would like to do this without overload. If templates are used, they should not cause crazy error messages. For example, the following code is
int a; DoSomething(a);
- should lead to a compilation error on the call site, not inside the template!
Does anyone have any ideas?
source share