| 1 |
.. title:: clang-tidy - hicpp-ignored-remove-result |
| 2 |
|
| 3 |
hicpp-ignored-remove-result |
| 4 |
=========================== |
| 5 |
|
| 6 |
Ensure that the result of ``std::remove``, ``std::remove_if`` and ``std::unique`` |
| 7 |
are not ignored according to |
| 8 |
`rule 17.5.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-standard/standard-library>`_. |
| 9 |
|
| 10 |
The mutating algorithms ``std::remove``, ``std::remove_if`` and both overloads |
| 11 |
of ``std::unique`` operate by swapping or moving elements of the range they are |
| 12 |
operating over. On completion, they return an iterator to the last valid |
| 13 |
element. In the majority of cases the correct behavior is to use this result as |
| 14 |
the first operand in a call to ``std::erase``. |
| 15 |
|
| 16 |
This check is a subset of :doc:`bugprone-unused-return-value <../bugprone/unused-return-value>` |
| 17 |
and depending on used options it can be superfluous to enable both checks. |
| 18 |
|
| 19 |
Options |
| 20 |
------- |
| 21 |
|
| 22 |
.. option:: AllowCastToVoid |
| 23 |
|
| 24 |
Controls whether casting return values to ``void`` is permitted. Default: `true`. |