c++ - C++11: std::vector::shrink_to_fit complexity -
the article @ cppreference.com tells complexity of std::vector::shrink_to_fit
constant. far know possible if elements not moved, because if complexity n. says all iterators, including past end iterator, potentially invalidated. means moving of elements defined possibility.
is article faulty? ... or there magic don't know about?
the article is faulty, fixed it.
while official standard doesn't complexity of std::vector::shrink_to_fit
, in n3376 changed wording, thereby fixing dr 2033:
23.3.6.3:
void shrink_to_fit();
requires:
t
shallmoveinsertable
*this
.complexity: linear in size of sequence.
Comments
Post a Comment