DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GlobalFunctions.h
1 
17 #pragma once
18 
33 #if defined(GlobalFunctions_RECURSES)
34 #error Recursive header files inclusion detected in GlobalFunctions.h
35 #else // defined(GlobalFunctions_RECURSES)
36 
37 #define GlobalFunctions_RECURSES
38 
39 #if !defined GlobalFunctions_h
40 
41 #define GlobalFunctions_h
42 
44 // Inclusions
45 #include <algorithm>
46 #include <functional>
47 #include "DGtal/base/Common.h"
49 
50 namespace DGtal
51 {
52 
63  template<typename T>
64  T minDGtal(const T & a, const T & b)
65  {
66  BOOST_CONCEPT_ASSERT((boost::EqualityComparable<T>));
67  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<T>));
68  if (a<=b)
69  return a;
70  else
71  return b;
72  }
73 
84  template<typename T>
85  T maxDGtal(const T & a, const T & b)
86  {
87  BOOST_CONCEPT_ASSERT((boost::EqualityComparable<T>));
88  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<T>));
89  if (a>=b)
90  return a;
91  else
92  return b;
93  }
94 
104  template<typename T>
105  T abs(const T & a)
106  {
107  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<T>));
108  if (a<0)
109  return -a;
110  else
111  return a;
112  }
113 
114 
115 }
117 
118 #endif // !defined GlobalFunctions_h
119 
120 #undef GlobalFunctions_RECURSES
121 #endif // else defined(GlobalFunctions_RECURSES)