This is NOT a duplicate of "Thou shalt not inherit from std::vector" which is asking about adding "algorithms" not methods.
Obviously there'd be a slicing problem if there were extra members, but there aren't.
There could be some other unexpected behavior if any methods were overiden, but they're not.
The spec says that deleting an object via a base-class pointer with a non-virtual destructor is undefined, but assume I have the self-control not to do that and that if I do, my implementation silently succeeds (as I assume all would; any known exceptions?)
There seems to be no problem with ref's or assignments to std vectors as the only things lost would be the additional methods.
Just off the cuff ideas for new methods that I find myself repeating constantly:
T& allow( size_t x ) { // grows the vector when necessary.
if ( size() <= x )
resize( x+1 );
}
T& ok( size_t x ) { // get lvalue, growing the vector when necessary.
allow( x );
return operator[]( x );
}
int size() { // return type is int, which is much more convenient; limits you to
// MAXINT elements but enough for all code I've written in 26 years.
return (int) vector<T>::size();
}
T& back( int i = 0 ) { // gives you back element, or indexed, gives Nth back.
return operator[]( size() - i - 1 );
}