template<typename T, typename A>
vector<T, A>::iterator vector<T, A>::insert(vector<T, A>::iterator p, const T &val)
{
int index = p - begin();
if (size() == capacity())
{
reserve(size() == 0 ? 8 : 2 * size()); // make sure we have space
}
// first copy last element into uninitialized space
alloc.construct(elem + sz, *back());
++sz;
iterator pp = begin() + index; // the place to put val
for (auto pos = end() - 1; pos != pp; --pos)
{
*pos = *(pos - 1); // copy elements one position to the right
}
*(begin() + index) = val; // "insert" val
return pp;
}
template<typename T, typename A>
vector<T, A>::iterator vector<T, A>::erase(vector<T, A>::iterator p)
{
if (p == end())
{
return p;
}
for (auto pos = p + 1; pos != end(); ++pos)
{
*(pos - 1) = *pos; // copyy element "one position to the left"
}
alloc.destroy(&*(end() - 1)); // destroy surplus copy of last element
--sz;
return p;
}
I've clearly done what it's asking, so why is it saying that?
If anyone wants to look at it in the context of the full header file (it's a header file I wrote), please let me know and I'll show it.
template<typename T, typename A>
typename vector<T, A>::iterator vector<T, A>::insert(vector<T, A>::iterator p, const T &val)
for insert() and erase().
So is it because the compiler needs to tell for sure that it's a typename alias for a vector::T* and not a greater-than or less-than comparison? Is that the reason for this?
Ah, so the proposal was made after the standard became feature-complete (or maybe just at such a time that it couldn't make it into the standard in time)?
Anyway, the initial problem has already been solved, so I'll mark it as such.