1 #ifndef _RHEO_MSG_UTIL_H
2 #define _RHEO_MSG_UTIL_H
31 # include "rheolef/distributed.h"
35 #ifndef RHEO_MPI_PRUDENCE
36 #define RHEO_MPI_PRUDENCE 0
40 template <
class T1,
class T2>
41 struct select1st : std::unary_function<std::pair<T1,T2>, T1> {
42 T1
operator() (
const std::pair<T1,T2>& x)
const {
return x.first; }
44 template <
class T1,
class T2>
45 struct select2nd : std::unary_function<std::pair<T1,T2>, T2> {
46 T2
operator() (
const std::pair<T1,T2>& x)
const {
return x.second; }
55 template <
class T1,
class T2>
56 struct set_op : std::binary_function<T1,T2,T1> {
57 T1&
operator()(T1& x,
const T2& y)
const {
return x = y; }
60 template <
class T1,
class T2>
62 T1&
operator()(T1& x,
const T2& y)
const {
return x += y; }
66 template <
class T,
class Distance = std::ptrdiff_t>
67 class dummy_iterator :
public std::iterator<std::input_iterator_tag, T, Distance, const T*, const T&> {
78 template <
class Size,
class Distance = std::ptrdiff_t>
79 class index_iterator :
public std::iterator<std::input_iterator_tag, Size, Distance, const Size*, const Size&> {
88 const Size&
operator[](
const Size& i)
const {
return i; }
92 return !(x.
_i ==
_i); }
101 :
public std::unary_function<Pair,typename Pair::first_type> {
102 typename std::unary_function<Pair,typename Pair::first_type>::result_type
107 template <
class Pair>
109 :
public std::unary_function<Pair, typename Pair::second_type> {
110 typename std::unary_function<Pair,typename Pair::second_type>::result_type
116 template<
class Pair1,
class Pair2>
119 return Pair2(x.first, x.second); }
122 template <
class Iterator,
class Operator>
139 template <
class Iterator,
class Operator>
146 template <
class InputIterator,
class OutputIterator>
149 OutputIterator result) {
150 while (input != last) {
151 (*result).first = (*input).first;
152 (*result++).second = (*input++).second;
157 #endif // _RHEO_MSG_UTIL_H