Namespaces
Variants
Views
Actions

Talk:cpp/container/vector/shrink to fit

From cppreference.com

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)