NiHu  2.0
misc.hpp
Go to the documentation of this file.
1 #ifndef MISC_H_INCLUDED
4 #define MISC_H_INCLUDED
5 
6 namespace NiHu
7 {
8 
9 
19 template <class InputIterator, class OutputIterator, class Predicate>
20 InputIterator move_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
21 {
22  InputIterator to = first;
23  while (first != last)
24  {
25  if (pred(*first))
26  *result++ = *first++;
27  else
28  *to++ = *first++;
29  }
30  return to;
31 }
32 
33 
34 } // namespace NiHu
35 
36 #endif
NiHu::move_if
InputIterator move_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
move selected elements from a range to an other
Definition: misc.hpp:20