| 40 |
|
*/ |
| 41 |
|
|
| 42 |
|
#include <functional> |
| 43 |
< |
|
| 43 |
> |
#include "config.h" |
| 44 |
|
namespace oopse { |
| 45 |
|
|
| 46 |
< |
/** |
| 47 |
< |
* copy_if is one of the missing functions in STL. |
| 48 |
< |
* copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), |
| 49 |
< |
* except that any element for which pred is false is not copied. |
| 50 |
< |
*/ |
| 51 |
< |
template<typename InputIterator, typename OutputIterator, typename Predicate> |
| 52 |
< |
OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate p) { |
| 46 |
> |
/** |
| 47 |
> |
* copy_if is one of the missing functions in STL. |
| 48 |
> |
* copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), |
| 49 |
> |
* except that any element for which pred is false is not copied. |
| 50 |
> |
*/ |
| 51 |
> |
template<typename InputIterator, typename OutputIterator, typename Predicate> |
| 52 |
> |
OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate p) { |
| 53 |
|
while (first != last) { |
| 54 |
< |
if (p(*first)) { |
| 55 |
< |
*result++ = *first; |
| 56 |
< |
} |
| 57 |
< |
++first; |
| 54 |
> |
if (p(*first)) { |
| 55 |
> |
*result++ = *first; |
| 56 |
> |
} |
| 57 |
> |
++first; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
return result; |
| 61 |
< |
} |
| 61 |
> |
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
< |
template<typename T> |
| 66 |
< |
struct logical_xor :public std::binary_function<T, T, bool> { |
| 67 |
< |
double operator()(T x, T y) { return x ^ y; } |
| 68 |
< |
}; |
| 65 |
> |
template<typename T> |
| 66 |
> |
struct logical_xor :public std::binary_function<T, T, bool> { |
| 67 |
> |
RealType operator()(T x, T y) { return x ^ y; } |
| 68 |
> |
}; |
| 69 |
|
|
| 70 |
|
} |