How to get the type of STL container from an object? For example, I have a container
variable and I know that it is std::vector<some type>
. I need to iterate the container using iterators. Is there a way to declare iterator without knowing the type of container?
I can get the type from the code of course, but I am curios to do it without using the type. Also I am not using C++11.
std::vector
of "some type"s ? – LihOcontainer
as a parameter, then the type has to be included -- unless it's a template, but even in that case you can use SFINAE to get what you need. – Chadcontainer
variable is a template parameter? Is that why you don't know the specific type? – Drew Dormannauto
is added to C++11 ! – Ajay