ECSTASY
All in the name
Loading...
Searching...
No Matches
Condition.hpp
Go to the documentation of this file.
1
11
12#ifndef ECSTASY_QUERY_CONDITIONS_CONDITION_HPP_
13#define ECSTASY_QUERY_CONDITIONS_CONDITION_HPP_
14
15#include <concepts>
16
17namespace ecstasy::query
18{
26 struct ConditionBase {};
27
42 template <auto Left, auto Right, typename Comparer>
43 struct Condition : public ConditionBase {};
44
45 // clang-format off
58 template <
59 typename LeftType, LeftType Left,
60 typename RightType, RightType Right,
61 typename Comparer>
62 requires(!std::is_member_pointer_v<LeftType> && !std::is_member_pointer_v<RightType>)
64 //clang-format on
65
74 static bool test()
75 {
76 return Comparer{}(Left, Right);
77 }
78 };
79
80
81 // clang-format off
95 template <
96 typename LeftType, LeftType Left,
97 typename RightType, typename RightValueType, RightValueType RightType::*ptr,
98 typename Comparer>
99 requires(!std::is_member_pointer_v<LeftType> && std::is_member_object_pointer_v<decltype(ptr)>)
100 struct Condition<Left, ptr, Comparer> : public ConditionBase {
101 //clang-format on
102 using Right = RightType;
103
114 static bool test(const RightType &right)
115 {
116 return Comparer{}(Left, right.*ptr);
117 }
118 };
119
120 // clang-format off
134 template <
135 typename LeftType, LeftType Left,
136 typename RightType, typename RightValueType, RightValueType (RightType::*ptr)(void) const,
137 typename Comparer>
138 requires(!std::is_member_pointer_v<LeftType> && std::is_member_function_pointer_v<decltype(ptr)>)
139 struct Condition<Left, ptr, Comparer> : public ConditionBase {
140 // clang-format on
141 using Right = RightType;
142
153 static bool test(const RightType &right)
154 {
155 return Comparer{}(Left, (right.*ptr)());
156 }
157 };
158
159 // clang-format off
173 template <
174 typename LeftType, typename LeftValueType, LeftValueType LeftType::*ptr,
175 typename RightType, RightType Right,
176 typename Comparer>
177 requires(std::is_member_object_pointer_v<decltype(ptr)> && !std::is_member_pointer_v<RightType>)
178 struct Condition<ptr, Right, Comparer> : public ConditionBase {
179 // clang-format on
180 using Left = LeftType;
181
192 static bool test(const LeftType &left)
193 {
194 return Comparer{}(left.*ptr, Right);
195 }
196 };
197
198 // clang-format off
213 template <
214 typename LeftType, typename LeftValueType, LeftValueType LeftType::*ptrLeft,
215 typename RightType, typename RightValueType, RightValueType RightType::*ptrRight,
216 typename Comparer>
217 requires(std::is_member_object_pointer_v<decltype(ptrLeft)> && std::is_member_object_pointer_v<decltype(ptrRight)>)
219 // clang-format on
220 using Left = LeftType;
221 using Right = RightType;
222
234 static bool test(const LeftType &left, const RightType &right)
235 {
236 return Comparer{}(left.*ptrLeft, right.*ptrRight);
237 }
238 };
239
240 // clang-format off
255 template <
256 typename LeftType, typename LeftValueType, LeftValueType LeftType::*ptrLeft,
257 typename RightType, typename RightValueType, RightValueType (RightType::*ptrRight)(void) const,
258 typename Comparer>
259 requires(std::is_member_object_pointer_v<decltype(ptrLeft)> && std::is_member_function_pointer_v<decltype(ptrRight)>)
260 struct Condition<ptrLeft, ptrRight, Comparer> : public ConditionBase {
261 // clang-format on
262 using Left = LeftType;
263 using Right = RightType;
264
276 static bool test(const LeftType &left, const RightType &right)
277 {
278 return Comparer{}(left.*ptrLeft, (right.*ptrRight)());
279 }
280 };
281
282 // clang-format off
296 template <
297 typename LeftType, typename LeftValueType, LeftValueType (LeftType::*ptr)(void) const,
298 typename RightType, RightType Right,
299 typename Comparer>
300 requires(std::is_member_function_pointer_v<decltype(ptr)> && !std::is_member_pointer_v<RightType>)
301 struct Condition<ptr, Right, Comparer> : public ConditionBase {
302 // clang-format on
303 using Left = LeftType;
304
315 static bool test(const LeftType &left)
316 {
317 return Comparer{}((left.*ptr)(), Right);
318 }
319 };
320
321 // clang-format off
336 template <
337 typename LeftType, typename LeftValueType, LeftValueType (LeftType::*ptrLeft)(void) const,
338 typename RightType, typename RightValueType, RightValueType RightType::*ptrRight,
339 typename Comparer>
340 requires(std::is_member_function_pointer_v<decltype(ptrLeft)> && std::is_member_object_pointer_v<decltype(ptrRight)>)
341 struct Condition<ptrLeft, ptrRight, Comparer> : public ConditionBase {
342 // clang-format on
343 using Left = LeftType;
344 using Right = RightType;
345
357 static bool test(const LeftType &left, const RightType &right)
358 {
359 return Comparer{}((left.*ptrLeft)(), right.*ptrRight);
360 }
361 };
362
363 // clang-format off
378 template <
379 typename LeftType, typename LeftValueType, LeftValueType (LeftType::*ptrLeft)(void) const,
380 typename RightType, typename RightValueType, RightValueType (RightType::*ptrRight)(void) const,
381 typename Comparer>
382 requires(std::is_member_function_pointer_v<decltype(ptrLeft)> && std::is_member_function_pointer_v<decltype(ptrRight)>)
383 struct Condition<ptrLeft, ptrRight, Comparer> : public ConditionBase {
384 // clang-format on
385 using Left = LeftType;
386 using Right = RightType;
387
399 static bool test(const LeftType &left, const RightType &right)
400 {
401 return Comparer{}((left.*ptrLeft)(), (right.*ptrRight)());
402 }
403 };
404} // namespace ecstasy::query
405
406#endif /* !ECSTASY_QUERY_CONDITIONS_CONDITION_HPP_ */
T is_member_object_pointer_v
Namespace regrouping the internal ecstasy query system.
Definition Condition.hpp:18
static bool test(const RightType &right)
Evaluate the condition.
static bool test(const LeftType &left)
Evaluate the condition.
static bool test(const LeftType &left, const RightType &right)
Evaluate the condition.
Base class for all conditions.
Definition Condition.hpp:26
Condition resolution structure.
Definition Condition.hpp:43