Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JComparisonAvailable.hh
Go to the documentation of this file.
1 
2 #ifndef __JLANG__JCOMPARISONAVAILABLE__
3 #define __JLANG__JCOMPARISONAVAILABLE__
4 
5 #include "JLang/JNullType.hh"
6 #include "JLang/JAnyType.hh"
7 #include "JLang/JVoid.hh"
8 #include "JLang/JTest.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JLANG {}
16 namespace JPP { using namespace JLANG; }
17 
18 namespace JLANG {
19 
20  namespace JLOCAL {
21 
22  /**
23  * Fallback implementations for comparison operators.
24  */
31 
32 
33  /**
34  * Test availability of comparison operators of non-composite data types.
35  */
36  template<class T, class JType_t = void>
38  public JTest
39  {
40  using JTest::test;
41 
42  static JTrue test(const bool&);
43 
44  static T& getReference();
45 
46  public:
47  static const bool has_eq = JTEST(test(getReference() == getReference())); //!< true if operator== available; else false
48  static const bool has_ne = JTEST(test(getReference() != getReference())); //!< true if operator!= available; else false
49  static const bool has_lt = JTEST(test(getReference() < getReference())); //!< true if operator< available; else false
50  static const bool has_gt = JTEST(test(getReference() > getReference())); //!< true if operator> available; else false
51  static const bool has_le = JTEST(test(getReference() <= getReference())); //!< true if operator<= available; else false
52  static const bool has_ge = JTEST(test(getReference() >= getReference())); //!< true if operator>= available; else false
53  };
54 
55 
56  /**
57  * Test availability of comparison operators of data types which have a type definitions for first_type and second_type.
58  * This applies to STL containers such as std::map.
59  * Note that STL provides for the comparison of the container based on comparisons of its elements.
60  */
61  template<class T>
62  class JComparisonAvailable<T, typename JVoid<typename T::second_type>::type>
63  {
64  typedef typename T::first_type first_type;
65  typedef typename T::second_type second_type;
66 
67  public:
74  };
75 
76 
77  /**
78  * Test availability of comparison operators of data types which have a type definition for value_type.
79  * This applies to STL containers such as std::vector and std::set.
80  * Note that STL provides for the comparison of the container based on comparisons of its elements.
81  */
82  template<class T>
83  class JComparisonAvailable<T, typename JVoid<typename T::value_type>::type> :
84  public JComparisonAvailable<typename T::value_type>
85  {};
86 
87 
88  /**
89  * Template base class for data structures without equality capability.
90  * This class implements the operators <tt> == != </tt>.
91  */
92  template<class T>
93  class JNoequals {
94  private:
95  /**
96  * Equal operator.
97  *
98  * \param first first object
99  * \param second second object
100  * \return true if two objects are equal; else false
101  */
102  friend JNullType operator==(const T& first, const T& second)
103  {
104  return JNullType();
105  }
106 
107 
108  /**
109  * Not equal operator.
110  *
111  * \param first first object
112  * \param second second object
113  * \return true if two objects are not equal; else false
114  */
115  friend JNullType operator!=(const T& first, const T& second)
116  {
117  return JNullType();
118  }
119  };
120  }
121 
123  using JLOCAL::JNoequals;
124 }
125 
126 #endif
friend JNullType operator==(const T &first, const T &second)
Equal operator.
#define JTEST(__A__)
Test macro.
Definition: JTest.hh:45
static JFalse test(...)
default false
Test availability of comparison operators of non-composite data types.
static const bool has_eq
true if operator== available; else false
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1263
friend JNullType operator!=(const T &first, const T &second)
Not equal operator.
static const bool has_lt
true if operator&lt; available; else false
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
JNullType operator>(JAnyType, JAnyType)
static const bool has_ge
true if operator&gt;= available; else false
Auxiliary class for any type definition.
Definition: JAnyType.hh:19
bool operator==(Packet const &p, ID const &id)
static const bool has_gt
true if operator&gt; available; else false
Auxiliary base class for compile time evaluation of test.
Definition: JTest.hh:21
definition of true
Definition: JTest.hh:24
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Auxiliary class for no type definition.
Definition: JNullType.hh:19
static const bool has_le
true if operator&lt;= available; else false
JNullType operator>=(JAnyType, JAnyType)
JNullType operator<=(JAnyType, JAnyType)
static const bool has_ne
true if operator!= available; else false
static JTrue test(const bool &)
Auxiliary class for void type definition.
Definition: JVoid.hh:20
JNullType operator!=(JAnyType, JAnyType)
Template base class for data structures without equality capability.