Test std::find()

This commit is contained in:
Daniel Marjamäki 2016-11-01 12:25:23 +01:00
parent 34e8ed6e31
commit 7f71ad8360
2 changed files with 32 additions and 1 deletions

View File

@ -4038,13 +4038,28 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<!-- InputIterator std::find(InputIterator first, InputIterator last, T val) --> <!-- InputIterator std::find(InputIterator first, InputIterator last, T val) -->
<!-- InputIterator std::find_if(InputIterator first, InputIterator last, UnaryPredicate val) --> <!-- InputIterator std::find_if(InputIterator first, InputIterator last, UnaryPredicate val) -->
<!-- InputIterator std::find_if_not(InputIterator first, InputIterator last, UnaryPredicate val) --> <!-- InputIterator std::find_if_not(InputIterator first, InputIterator last, UnaryPredicate val) -->
<!-- InputIterator std::for_each(InputIterator first, InputIterator last, Function func) -->
<!-- bool std::all_of(InputIterator first, InputIterator last, UnaryPredicate pred) --> <!-- bool std::all_of(InputIterator first, InputIterator last, UnaryPredicate pred) -->
<!-- bool std::any_of(InputIterator first, InputIterator last, UnaryPredicate pred) --> <!-- bool std::any_of(InputIterator first, InputIterator last, UnaryPredicate pred) -->
<!-- bool std::none_of(InputIterator first, InputIterator last, UnaryPredicate pred) --> <!-- bool std::none_of(InputIterator first, InputIterator last, UnaryPredicate pred) -->
<!-- InputIterator std::count(InputIterator first, InputIterator last, T val) --> <!-- InputIterator std::count(InputIterator first, InputIterator last, T val) -->
<!-- InputIterator std::count_if(InputIterator first, InputIterator last, UnaryPredicate val) --> <!-- InputIterator std::count_if(InputIterator first, InputIterator last, UnaryPredicate val) -->
<function name="std::find,std::find_if,std::find_if_not,std::count,std::count_if,std::all_of,std::any_of,std::none_of"> <function name="std::find,std::find_if,std::find_if_not,std::count,std::count_if,std::all_of,std::any_of,std::none_of">
<use-retval/>
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>
<iterator container="1" type="first"/>
</arg>
<arg nr="2">
<not-uninit/>
<iterator container="1" type="last"/>
</arg>
<arg nr="3">
<not-uninit/>
</arg>
</function>
<!-- Function std::for_each(InputIterator first, InputIterator last, Function func) -->
<function name="std::for_each">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<arg nr="1"> <arg nr="1">
<not-uninit/> <not-uninit/>

View File

@ -3157,3 +3157,19 @@ void nullPointer_wmemcmp(wchar_t *p)
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
(void)std::wmemcmp(p, 0, 123); (void)std::wmemcmp(p, 0, 123);
} }
///////////////////////////////////////////////////////////////////////
// <algorithm>
///////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <list>
void stdfind(const std::list<int> &ints1, const std::list<int> &ints2) {
std::list<int>::const_iterator it;
// cppcheck-suppress mismatchingContainers
// cppcheck-suppress ignoredReturnValue
std::find(ints1.begin(), ints2.end(), 123);
// TODO cppcheck-suppress mismatchingContainers
if (std::find(ints1.begin(), ints1.end(), 123) == ints2.end()){}
}