Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;11:std::vector::收缩以适应复杂性_C++_C++11_Stl_Time Complexity - Fatal编程技术网

C++ C++;11:std::vector::收缩以适应复杂性

C++ C++;11:std::vector::收缩以适应复杂性,c++,c++11,stl,time-complexity,C++,C++11,Stl,Time Complexity,表示std::vector::shrink_to_fit的复杂性是恒定的。据我所知,只有在元素不移动的情况下才有可能,因为如果元素不移动,那么复杂性为n。它还说,所有迭代器,包括过去的结束迭代器,都可能无效。这意味着元素的移动是一种明确定义的可能性 这篇文章有错吗。。。还是有什么我不知道的魔法?这篇文章有问题,我修复了它 虽然官方标准没有说明std::vector::shrink_to_fit的复杂性,但在N3376中,他们更改了措辞,从而修复了DR 2033: 23.3.6.3: void s

表示std::vector::shrink_to_fit的复杂性是恒定的。据我所知,只有在元素不移动的情况下才有可能,因为如果元素不移动,那么复杂性为n。它还说,所有迭代器,包括过去的结束迭代器,都可能无效。这意味着元素的移动是一种明确定义的可能性

这篇文章有错吗。。。还是有什么我不知道的魔法?

这篇文章有问题,我修复了它

虽然官方标准没有说明
std::vector::shrink_to_fit
的复杂性,但在N3376中,他们更改了措辞,从而修复了DR 2033:

23.3.6.3:

void shorn_to_fit()

要求:
T
可移动插入
*此

复杂性:序列的大小是线性的


您可能引用了一个草稿-在C++11标准中没有关于
std::vector::shrink\u to_fit()
复杂性的内容。@MichaelBurr:是的,他们在N3376中更改了它。我明白了-有趣的是,他们没有添加
basic_string::shrink\u to_fit()
(还没有?).也许你应该在你的回答中澄清这是一个特定的草稿。(这篇文章很快就被修改了。所以最初的陈述现在是错误的。)