Jpp  17.3.2
the software that should make you happy
 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  /**
21  * Local namespace for fallback implementations for comparison operators.
22  */
23  namespace JLOCAL {
24 
25  /**
26  * Fallback implementations for comparison operators.
27  */
34 
35 
36  /**
37  * Test availability of comparison operators of non-composite data types.
38  */
39  template<class T, class JType_t = void>
41  public JTest
42  {
43  using JTest::test;
44 
45  static JTrue test(const bool&);
46 
47  static T& getReference();
48 
49  public:
50  static const bool has_eq = JTEST(test(getReference() == getReference())); //!< true if operator== available; else false
51  static const bool has_ne = JTEST(test(getReference() != getReference())); //!< true if operator!= available; else false
52  static const bool has_lt = JTEST(test(getReference() < getReference())); //!< true if operator< available; else false
53  static const bool has_gt = JTEST(test(getReference() > getReference())); //!< true if operator> available; else false
54  static const bool has_le = JTEST(test(getReference() <= getReference())); //!< true if operator<= available; else false
55  static const bool has_ge = JTEST(test(getReference() >= getReference())); //!< true if operator>= available; else false
56  };
57 
58 
59  /**
60  * Test availability of comparison operators of data types which have a type definitions for first_type and second_type.
61  * This applies to STL containers such as std::map.
62  * Note that STL provides for the comparison of the container based on comparisons of its elements.
63  */
64  template<class T>
65  class JComparisonAvailable<T, typename JVoid<typename T::second_type>::type>
66  {
67  typedef typename T::first_type first_type;
68  typedef typename T::second_type second_type;
69 
70  public:
77  };
78 
79 
80  /**
81  * Test availability of comparison operators of data types which have a type definition for value_type.
82  * This applies to STL containers such as std::vector and std::set.
83  * Note that STL provides for the comparison of the container based on comparisons of its elements.
84  */
85  template<class T>
86  class JComparisonAvailable<T, typename JVoid<typename T::value_type>::type> :
87  public JComparisonAvailable<typename T::value_type>
88  {};
89 
90 
91  /**
92  * Template base class for data structures without equality capability.
93  * This class implements the operators <tt> == != </tt>.
94  */
95  template<class T>
96  class JNoequals {
97  private:
98  /**
99  * Equal operator.
100  *
101  * \param first first object
102  * \param second second object
103  * \return true if two objects are equal; else false
104  */
105  friend JNullType operator==(const T& first, const T& second)
106  {
107  return JNullType();
108  }
109 
110 
111  /**
112  * Not equal operator.
113  *
114  * \param first first object
115  * \param second second object
116  * \return true if two objects are not equal; else false
117  */
118  friend JNullType operator!=(const T& first, const T& second)
119  {
120  return JNullType();
121  }
122  };
123  }
124 
126  using JLOCAL::JNoequals;
127 }
128 
129 #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:1741
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.