framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
comparable.hpp
Go to the documentation of this file.
1 // Copyright (C) 2012 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
31 #pragma once
32 
34 
35 namespace framework
36 {
37  namespace serializable
38  {
39  namespace detail
40  {
41  template <typename LhsNames, typename RhsNames>
42  struct compare;
43  }
44 
48  template <typename LhsType, typename RhsType>
49  bool less (LhsType const& lhs, RhsType const& rhs)
50  {
51  return detail::compare <
54  >::less(lhs, rhs);
55  }
56 
60  template <typename LhsType, typename RhsType>
61  bool greater (LhsType const& lhs, RhsType const& rhs)
62  {
63  return detail::compare <
66  >::greater(lhs, rhs);
67  }
68 
72  template <typename LhsType, typename RhsType>
73  bool less_or_equal (LhsType const& lhs, RhsType const& rhs)
74  {
75  return detail::compare <
78  >::less_or_equal(lhs, rhs);
79  }
80 
84  template <typename LhsType, typename RhsType>
85  bool greater_or_equal (LhsType const& lhs, RhsType const& rhs)
86  {
87  return detail::compare <
90  >::greater_or_equal(lhs, rhs);
91  }
92 
96  template <typename LhsType, typename RhsType>
97  bool equal (LhsType const& lhs, RhsType const& rhs)
98  {
99  return detail::compare <
102  >::equal(lhs, rhs);
103  }
104 
108  template <typename LhsType, typename RhsType>
109  bool not_equal (LhsType const& lhs, RhsType const& rhs)
110  {
111  return detail::compare <
114  >::not_equal(lhs, rhs);
115  }
116 
126  template <typename Parent>
127  struct comparable
128  {
133  friend bool operator< (Parent const& lhs, Parent const& rhs)
134  {
135  return less(lhs, rhs);
136  }
137 
142  friend bool operator> (Parent const& lhs, Parent const& rhs)
143  {
144  return greater(lhs, rhs);
145  }
146 
151  friend bool operator<= (Parent const& lhs, Parent const& rhs)
152  {
153  return less_or_equal(lhs, rhs);
154  }
155 
160  friend bool operator>= (Parent const& lhs, Parent const& rhs)
161  {
162  return greater_or_equal(lhs, rhs);
163  }
164 
169  friend bool operator== (Parent const& lhs, Parent const& rhs)
170  {
171  return equal(lhs, rhs);
172  }
173 
178  friend bool operator!= (Parent const& lhs, Parent const& rhs)
179  {
180  return not_equal(lhs, rhs);
181  }
182  };
183  }
184 }
185 
186 #include <framework/serializable/utility/comparable.inl>