brintos

brintos / llvm-project-archived public Read only

0
0
Text · 841 B · b2dcdd5 Raw
30 lines · plain
1.. title:: clang-tidy - bugprone-inaccurate-erase2 3bugprone-inaccurate-erase4=========================5 6 7Checks for inaccurate use of the ``erase()`` method.8 9Algorithms like ``remove()`` do not actually remove any element from the10container but return an iterator to the first redundant element at the end11of the container. These redundant elements must be removed using the12``erase()`` method. This check warns when not all of the elements will be13removed due to using an inappropriate overload.14 15For example, the following code erases only one element:16 17.. code-block:: c++18 19  std::vector<int> xs;20  ...21  xs.erase(std::remove(xs.begin(), xs.end(), 10));22 23Call the two-argument overload of ``erase()`` to remove the subrange:24 25.. code-block:: c++26 27  std::vector<int> xs;28  ...29  xs.erase(std::remove(xs.begin(), xs.end(), 10), xs.end());30