Standard C++ Library Class Reference
}
Output :
9 8 7 6 5 4 3 2 1 0
4 3 2 1 0
Warnings
Member function templates are used in all containers provided by the Standard Template Library. An
example of this feature is the constructor for vector<T, Allocator> that takes two templated iterators:
template <class InputIterator>
vector (InputIterator, InputIterator,
const Allocator = Allocator());
vector also has an insert function of this type. These functions, when not restricted by compiler
limitations, allow you to use any type of input iterator as arguments. For compilers that do not
support this feature we provide substitute functions that allow you to use an iterator obtained from the
same type of container as the one you are constructing (or calling a member function on), or you can
use a pointer to the type of element you have in the container.
For example, if your compiler does not support member function templates you can construct a
vector in the following two ways:
int intarray[10];
vector<int, allocator> first_vector(intarray, intarray + 10);
vector<int, allocator> second_vector(first_vector.begin(),
first_vector.end());
but not this way:
vector<long, allocator>
long_vector(first_vector.begin(),first_vector.end());
since the long_vector and first_vector are not the same type.
Additionally, if your compiler does not support default template parameters, you will need to supply
the Allocator template argument. For instance, you will need to write :
vector<int, allocator>
instead of :
vector<int>
See Also
allocator, Containers, Iterators, lexicographical_compare