cppcheck 2.18.0 suggests using std::find_if where it can't be simply applied:
#include <vector> bool get_index(const std::vector<int> & items, int value, size_t & index) { size_t current_index = 0; size_t count = items.size(); for (size_t i = 0; i < count; ++i) { if (items[i] == value) { if (current_index != index) { current_index++; continue; } index = i; return true; } } return false; } int main() { std::vector<int> items; items.push_back(0); items.push_back(1); items.push_back(1); items.push_back(1); size_t index = 2; get_index(items, 1, index); return 0; }
test\main.cpp:10:3: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] { ^
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14047
Log in to post a comment.
cppcheck 2.18.0 suggests using std::find_if where it can't be simply applied:
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14047