Consider the following pseudocode:
template<class Container>
int some_function(const Container& container)
{
if (container has iterator) { //
// get an element by its iterator
} else {
// do another action
}
}
So, we have a function template which takes a container type(e.g., vector, list, valarray or something else). Is it possible to determine (runtime) if a given container has iterator type? Compile time?
STLcontainer then it has an iterator. But it is usually more flexible/reusable to take iterators as parameters rather than the container. - Galik