| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2019 INRIA |
| 3 |
|
|
// |
| 4 |
|
|
|
| 5 |
|
|
#ifndef __pinocchio_math_comparison_operators_hpp__ |
| 6 |
|
|
#define __pinocchio_math_comparison_operators_hpp__ |
| 7 |
|
|
|
| 8 |
|
|
namespace pinocchio |
| 9 |
|
|
{ |
| 10 |
|
|
|
| 11 |
|
|
#define PINOCCHIO_DEFINE_COMPARISON_OP(name, OP) \ |
| 12 |
|
|
struct name \ |
| 13 |
|
|
{ \ |
| 14 |
|
|
template<typename T1, typename T2> \ |
| 15 |
|
|
static bool call(const T1 & a, const T2 & b) \ |
| 16 |
|
|
{ \ |
| 17 |
|
|
return a OP b; \ |
| 18 |
|
|
} \ |
| 19 |
|
|
} |
| 20 |
|
|
|
| 21 |
|
|
PINOCCHIO_DEFINE_COMPARISON_OP(equal_to_op, ==); |
| 22 |
|
|
PINOCCHIO_DEFINE_COMPARISON_OP(not_equal_to_op, !=); |
| 23 |
|
|
PINOCCHIO_DEFINE_COMPARISON_OP(less_than_op, <); |
| 24 |
|
|
PINOCCHIO_DEFINE_COMPARISON_OP(greater_than_op, >); |
| 25 |
|
40020 |
PINOCCHIO_DEFINE_COMPARISON_OP(less_than_or_equal_to_op, <=); |
| 26 |
|
|
PINOCCHIO_DEFINE_COMPARISON_OP(greater_than_or_equal_to_op, >=); |
| 27 |
|
|
|
| 28 |
|
|
template<class OP, bool condition, bool default_return_value> |
| 29 |
|
|
struct apply_op_if |
| 30 |
|
|
{ |
| 31 |
|
|
template<typename T1, typename T2> |
| 32 |
|
668 |
static bool op(const T1 & /*a*/, const T2 & /*b*/) |
| 33 |
|
|
{ |
| 34 |
|
668 |
return default_return_value; |
| 35 |
|
|
} |
| 36 |
|
|
}; |
| 37 |
|
|
|
| 38 |
|
|
template<class OP, bool default_return_value> |
| 39 |
|
|
struct apply_op_if<OP, true, default_return_value> |
| 40 |
|
|
{ |
| 41 |
|
|
template<typename T1, typename T2> |
| 42 |
|
40020 |
static bool op(const T1 & a, const T2 & b) |
| 43 |
|
|
{ |
| 44 |
|
40020 |
return OP::call(a, b); |
| 45 |
|
|
} |
| 46 |
|
|
}; |
| 47 |
|
|
} // namespace pinocchio |
| 48 |
|
|
|
| 49 |
|
|
#endif // #ifndef __pinocchio_math_comparison_operators_hpp__ |
| 50 |
|
|
|