AFF --- A container for numbers (array) by Friederich and Forbriger.
max.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef AFF_MAX_H_VERSION
38 
39 #define AFF_MAX_H_VERSION \
40  "AFF_MAX_H V1.1 "
41 
42 #include<aff/lib/collector.h>
43 
44 namespace aff {
45 
46  namespace func {
47 
48  namespace util {
49 
57  template<class C>
58  class Extractmax {
59  typedef typename C::Tcoc Tcont;
60  typedef typename C::Tvalue Tvalue;
61  public:
62  typedef Tvalue Tretval;
64  Extractmax(const Tcont& c): Mval(c(c.first())) { }
66  void operator() (const Tvalue& v)
67  { Mval = Mval > v ? Mval : v; }
69  Tretval result() const { return(Mval); }
70  private:
72  }; // class Extractmax
73 
74  } // namespace util
75 
76 /*----------------------------------------------------------------------*/
77 
88  template<class C>
89  typename C::Tvalue max(const C& c)
90  {
91  return(aff::func::util::collect<C, aff::func::util::Extractmax>(c));
92  } // max()
93 
94  } // namespace func
95 
96 } // namespace aff
97 
98 #endif // AFF_MAX_H_VERSION (includeguard)
99 
100 /* ----- END OF max.h ----- */
Root namespace of library.
Definition: array.h:148
collect values (prototypes)
Tretval result() const
return result of operation
Definition: max.h:69
void operator()(const Tvalue &v)
collect another value
Definition: max.h:66
C::Tvalue max(const C &c)
Definition: max.h:89
Extractmax(const Tcont &c)
initialize member data
Definition: max.h:64