rheolef  6.5
functional_sgi_ext.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_FUNCTIONAL_SGI_EXT_H
2 #define _RHEOLEF_FUNCTIONAL_SGI_EXT_H
3 namespace rheolef {
4  template <class _Operation1, class _Operation2>
6  : public std::unary_function<typename _Operation2::argument_type,
7  typename _Operation1::result_type>
8  {
9  protected:
10  _Operation1 _M_fn1;
11  _Operation2 _M_fn2;
12 
13  public:
14  unary_compose(const _Operation1& __x, const _Operation2& __y)
15  : _M_fn1(__x), _M_fn2(__y) {}
16 
17  typename _Operation1::result_type
18  operator()(const typename _Operation2::argument_type& __x) const
19  { return _M_fn1(_M_fn2(__x)); }
20  };
21 
22  template <class _Operation1, class _Operation2>
23  inline unary_compose<_Operation1, _Operation2>
24  compose1(const _Operation1& __fn1, const _Operation2& __fn2)
25  { return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); }
26 
27  template <class _Operation1, class _Operation2, class _Operation3>
29  : public std::unary_function<typename _Operation2::argument_type,
30  typename _Operation1::result_type>
31  {
32  protected:
33  _Operation1 _M_fn1;
34  _Operation2 _M_fn2;
35  _Operation3 _M_fn3;
36 
37  public:
38  binary_compose(const _Operation1& __x, const _Operation2& __y,
39  const _Operation3& __z)
40  : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
41 
42  typename _Operation1::result_type
43  operator()(const typename _Operation2::argument_type& __x) const
44  { return _M_fn1(_M_fn2(__x), _M_fn3(__x)); }
45  };
46 
47  template <class _Operation1, class _Operation2, class _Operation3>
48  inline binary_compose<_Operation1, _Operation2, _Operation3>
49  compose2(const _Operation1& __fn1, const _Operation2& __fn2,
50  const _Operation3& __fn3)
52  (__fn1, __fn2, __fn3); }
53 
54 } // namespace rheolef
55 #endif // _RHEOLEF_FUNCTIONAL_SGI_EXT_H
56