aimstil  5.0.5
sandbox.h
Go to the documentation of this file.
1 #ifndef TIL_SANDBOX_H
2 #define TIL_SANDBOX_H
3 
4 namespace til
5 {
6 
7  /*
8  template < typename TContainer >
9  struct All
10  {
11  All(const TContainer & c) : m_c(c) {}
12  const TContainer & m_c;
13  };
14 
15  template < typename TContainer >
16  inline All<TContainer> all(const TContainer & c) { return All<TContainer>(c); }
17 
18  template < typename TContainer1, typename TContainer2 >
19  inline bool operator<(const All<TContainer1> & c1, const All<TContainer2> & c2)
20  {
21  }
22  */
23 
24 
25  namespace
26  {
27  // Small helper for the following
28  template < typename T >
29  inline void minto(T & x, T y)
30  {
31  if (x>y) x=y;
32  }
33  }
34 
35 
36  template < typename TRange >
37  inline
38  typename boost::enable_if<is_range<TRange>, typename TRange::value_type>::type
39  min(TRange r)
40  {
41  typedef typename TRange::value_type value_type;
42  // We don't want to use numeric_limits because this function might be useful for
43  // non numerical types.
44  if (!r.ok()) return value_type();
45  value_type res = *r;
46  for (; r.ok(); ++r)
47  {
48  // The function call is simply to avoid calling *r twice, as well
49  // as to explicitely creating a temporary variable if not needed.
50  // TODO: helper func is not working, maybe there is a pb in the typedefs
51  // in range.
52  if (res > *r) res = *r;
53  }
54  return res;
55  }
56 }
57 
58 
59 #endif
60 
boost::enable_if< is_Image< TImage >, typename TImage::value_type >::type min(const TImage &im)
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10