detect performance-unnecessary-value-param
when used methods have const
versions
#59750
Labels
performance-unnecessary-value-param
when used methods have const
versions
#59750
https://godbolt.org/z/8v9vhdcdq
In all the cases above the given container is never modified so it is possible to change it to a const reference instead.
In case of
begin()
/end()
the code can beconst
-ified so the warning will be able to catch it. In case of a method likefront()
orback()
there's is no version that explicitly returns a constant value (likecfront()
orcback()
). To trigger this warning the code could awkwardly be changed to use*cbegin()
or*std::prev(cback())
instead.It would be great if it could be detected that no refence to the vector is being used and the warning is triggered.
I assume there's possibly cases for other methods and containers.
The text was updated successfully, but these errors were encountered: