Talk:cpp/container/vector/shrink to fit

The complexity is bad. It is not constant, but linear.

23.3.6.3:

void shrink_to_fit;

Requires: T shall be MoveInsertable into *this.

Complexity: Linear in the size of the sequence.


 * You are not quoting the C++11 standard document, you're quoting the C++14 working draft. This particular change (type requirement and complexity for shrink_to_fit) were part of the resolution to the library issue #2033 --Cubbi 03:27, 13 May 2013 (PDT)

Pointer invalidation
The note about invalidation should talk about references, *pointers* and iterators. I'm not familiar enough with the wiki markup to do the change myself.
 * there is nothing special about pointers: they are invalidated when (because) the references are. The standard does mention pointers when discussing vector::shrink_to_fit, but in many other situations it only talks about iterators and references: associative.reqmts/9, unord.req/14, deque.modifiers/1, deque.modifiers/4, forwardlist.modifiers/1, forwardlist.ops/12, forwardlist.ops/16 (I stopped grepping at this point). Are pointers really worth the effort to list separately? --Cubbi (talk) 05:58, 5 July 2017 (PDT)