0

Anyone know how to make a function parameter so that any stl container(vector, list, deque etc) can use it if we need to in cpp?

The function just prints the container

25th Nov 2021, 8:49 PM
Kareem Idris
2 Respostas
+ 2
Can you add a brief explanation in the Description about what the function does with the container?
25th Nov 2021, 10:42 PM
Ipang
0
Kareem, I'm not sure whether this answers your query, but if the container supports forward iteration (by the use of std::begin() and std::end()), I guess it is possible by implementing template for the function. Some containers e.g. std::bitset, std::queue, std::stack apparently are not implemented with forward or random direction iterator, so they might not be an option. std::deque however, does implement iterators.
29th Nov 2021, 6:52 AM
Ipang