只有在病媒生长时才会重新定位。 <代码>erase或erase_if/code>在逻辑上不可能使病媒大于原样。 永远不会发生重新分配。
As far as which one is more "efficient" that s mostly meaningless. The two methods are not comparable replacements for each other. If one needs to select values to remove based on some logical criteria, anything other than a fixed value, erase_if
is your only option. No matter how hard you ll try you won t accomplish your goals with erase
, but only erase_if
, no matter how much the former is or is not "efficient".
在只需要删除固定价值的情况下,大多数现代C++汇编者很可能最终产生类似的(如果不是相同的话)代码:<代码>erase和erase_if
。 但是,随着现代的多国集团(CPU)的形成,很难说明差异;然而,<代码>erase导致更短的简单代码,而C++则不太明智。 这是一件好事。