Originally Posted by
anon
Because the signature of the constructor is as follows:
Code:
template <class Iter>
vector(Iter from, Iter to)
where Iter can be a suitable pointer, vector::iterator, list::iterator, my_random_sequence_generator::iterator etc.
As you can see both arguments must be of the
same type.
Well, you can see that, but it wasn't immediately apparent to me (although, thinking about it now, it does make sense that that should be the case). I have to say I'm still not accustomed to consulting official iso standards on a regular basis. I was looking at this (from cppreference.com):
Code:
#include <vector>
vector();
vector( const vector& c );
vector( size_type num, const TYPE& val = TYPE() );
vector( input_iterator start, input_iterator end );
~vector();
which doesn't seem to say that the two iterators must be of the same type. Now I see, in the iso standard (which you seem to be paraphrasing),
Code:
23.2.4.1 vector constructors, copy, and assignment
vector(const Allocator& = Allocator());
explicit vector(size_type n, const T& value = T(),
const Allocator& = Allocator());
template <class InputIterator>
vector(InputIterator first, InputIterator last,
const Allocator& = Allocator());
vector(const vector<T,Allocator>& x);
but that seems to be a pretty "clunky" source for frequent reference.
Do you know of a convenient online reference that provides more details than cppreference.com?