Add support for std::copy_n/merge/stable_sort (#4467)
* Add support for std::copy_n/merge/stable_sort * Format
This commit is contained in:
parent
d1386a842a
commit
7111270d5f
59
cfg/std.cfg
59
cfg/std.cfg
|
@ -7487,6 +7487,24 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
|
||||||
<iterator container="2" type="first"/>
|
<iterator container="2" type="first"/>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- template< class InputIt, class Size, class OutputIt > OutputIt copy_n( InputIt first, Size count, OutputIt result ); -->
|
||||||
|
<function name="std::copy_n">
|
||||||
|
<returnValue type="iterator" container="2"/>
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="1" type="first"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<not-uninit/>
|
||||||
|
<not-bool/>
|
||||||
|
<valid>0:</valid>
|
||||||
|
</arg>
|
||||||
|
<arg nr="3">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="2" type="first"/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<!-- template <class RandomAccessIterator> void std::sort (RandomAccessIterator first, RandomAccessIterator last); (until C++20) -->
|
<!-- template <class RandomAccessIterator> void std::sort (RandomAccessIterator first, RandomAccessIterator last); (until C++20) -->
|
||||||
<!-- template <class RandomAccessIterator> constexpr void std::sort (RandomAccessIterator first, RandomAccessIterator last); (since C++20) -->
|
<!-- template <class RandomAccessIterator> constexpr void std::sort (RandomAccessIterator first, RandomAccessIterator last); (since C++20) -->
|
||||||
<!-- @todo: template< class ExecutionPolicy, class RandomIt > void std::sort (ExecutionPolicy&& policy, RandomIt first, RandomIt last); (since C++17) -->
|
<!-- @todo: template< class ExecutionPolicy, class RandomIt > void std::sort (ExecutionPolicy&& policy, RandomIt first, RandomIt last); (since C++17) -->
|
||||||
|
@ -7505,6 +7523,47 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
|
||||||
<iterator container="1" type="last"/>
|
<iterator container="1" type="last"/>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- template< class RandomIt> void stable_sort( RandomIt first, RandomIt last ); -->
|
||||||
|
<!-- @todo: template< class ExecutionPolicy, class RandomIt > void stable_sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last ); (since C++17) -->
|
||||||
|
<!-- @todo: template< class RandomIt, class Compare > void stable_sort( RandomIt first, RandomIt last, Compare comp ); -->
|
||||||
|
<!-- @todo: template< class ExecutionPolicy, class RandomIt, class Compare > void stable_std::sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last, Compare comp ); (since C++17) -->
|
||||||
|
<function name="std::stable_sort">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="void"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="1" type="first"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="1" type="last"/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
|
<!-- template< class InputIt1, class InputIt2, class OutputIt > OutputIt merge( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first ); -->
|
||||||
|
<function name="std::merge">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="iterator" container="3"/>
|
||||||
|
<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/>
|
||||||
|
<iterator container="2" type="first"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="4">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="2" type="last"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="5">
|
||||||
|
<not-uninit/>
|
||||||
|
<iterator container="3" type="first"/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<!-- template< class RandomIt > void std::random_shuffle( RandomIt first, RandomIt last ); (deprecated in C++14) (removed in C++17) -->
|
<!-- template< class RandomIt > void std::random_shuffle( RandomIt first, RandomIt last ); (deprecated in C++14) (removed in C++17) -->
|
||||||
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc& r ); (until C++11) -->
|
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc& r ); (until C++11) -->
|
||||||
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc&& r ); (since C++11) (deprecated in C++14) (removed in C++17) -->
|
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc&& r ); (since C++11) (deprecated in C++14) (removed in C++17) -->
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
int zerodiv_ldexp()
|
int zerodiv_ldexp()
|
||||||
{
|
{
|
||||||
|
@ -2975,6 +2976,27 @@ void uninitvar_qsort(void)
|
||||||
(void)std::qsort(base,n,size, (int (*)(const void*,const void*))strcmp); // cppcheck-suppress cstyleCast
|
(void)std::qsort(base,n,size, (int (*)(const void*,const void*))strcmp); // cppcheck-suppress cstyleCast
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitvar_stable_sort(std::vector<int>& v)
|
||||||
|
{
|
||||||
|
std::vector<int>::iterator end;
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
std::stable_sort(v.begin(), end);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninitvar_merge(const std::vector<int>& a, const std::vector<int>& b)
|
||||||
|
{
|
||||||
|
std::vector<int>::iterator dst;
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
std::merge(a.begin(), a.end(), b.begin(), b.end(), dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninitvar_copy_n(const std::vector<int>& v)
|
||||||
|
{
|
||||||
|
std::vector<int>::iterator dst;
|
||||||
|
// cppcheck-suppress [uninitvar, invalidFunctionArg]
|
||||||
|
std::copy_n(v.begin(), -1, dst);
|
||||||
|
}
|
||||||
|
|
||||||
void uninitvar_putc(void)
|
void uninitvar_putc(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
Loading…
Reference in New Issue