Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JComparisonToolkit.hh
Go to the documentation of this file.
1 #ifndef __JEEP__JCOMPARISONTOOLKIT__
2 #define __JEEP__JCOMPARISONTOOLKIT__
3 
4 #include <string.h>
5 
7 #include "JLang/JBool.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JEEP {}
15 namespace JPP { using namespace JEEP; }
16 
17 namespace JEEP {
18 
20  using JLANG::JBool;
21 
22 
23 
24  /**
25  * Comparison of comparable objects.
26  *
27  * \param first first object
28  * \param second second object
29  * \return true if objects are equal; else false
30  */
31  template<class T>
32  inline bool compareObjects(const T& first,
33  const T& second,
35  {
36  return first == second;
37  }
38 
39 
40  /**
41  * Comparison of uncomparable objects.
42  *
43  * \param first first object
44  * \param second second object
45  * \return false
46  */
47  template<class T>
48  inline bool compareObjects(const T& first,
49  const T& second,
51  {
52  return false;
53  }
54 
55 
56  /**
57  * Comparison of objects.
58  *
59  * \param first first object
60  * \param second second object
61  * \return true if objects are comparable and equal; else false
62  */
63  template<class T>
64  inline bool compareObjects(const T& first,
65  const T& second)
66  {
67  return compareObjects(first, second, JBool<JComparisonAvailable<T>::has_eq>());
68  }
69 
70 
71  /**
72  * Comparison of comparable objects.
73  *
74  * \param first first object
75  * \param second second object
76  * \return true if objects are equal; else false
77  */
78  template<int N>
79  inline bool compareObjects(const char (&first) [N],
80  const char (&second)[N])
81  {
82  return strcmp(first, second) == 0;
83  }
84 
85 }
86 
87 #endif
Template definition of test availability of comparison operators.
General puprpose classes and methods.
bool compareObjects(const char(&first)[N], const char(&second)[N])
Comparison of comparable objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary template class for type bool.
Definition: JBool.hh:21