1.. title:: clang-tidy - bugprone-inaccurate-erase 2 3bugprone-inaccurate-erase 4========================= 5 6 7Checks for inaccurate use of the ``erase()`` method. 8 9Algorithms like ``remove()`` do not actually remove any element from the 10container but return an iterator to the first redundant element at the end 11of the container. These redundant elements must be removed using the 12``erase()`` method. This check warns when not all of the elements will be 13removed 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