GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/pinocchio/math/comparison-operators.hpp Lines: 3 3 100.0 %
Date: 2024-01-23 21:41:47 Branches: 0 0 - %

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
      { return a OP b;} \
17
    }
18
19
  PINOCCHIO_DEFINE_COMPARISON_OP(equal_to_op,==);
20
  PINOCCHIO_DEFINE_COMPARISON_OP(not_equal_to_op,!=);
21
  PINOCCHIO_DEFINE_COMPARISON_OP(less_than_op,<);
22
  PINOCCHIO_DEFINE_COMPARISON_OP(greater_than_op,>);
23
26568
  PINOCCHIO_DEFINE_COMPARISON_OP(less_than_or_equal_to_op,<=);
24
  PINOCCHIO_DEFINE_COMPARISON_OP(greater_than_or_equal_to_op,>=);
25
26
27
  template<class OP, bool condition, bool default_return_value>
28
  struct apply_op_if
29
  {
30
    template<typename T1, typename T2>
31
    static bool op(const T1 & /*a*/, const T2 & /*b*/)
32
    {
33
      return default_return_value;
34
    }
35
  };
36
37
  template<class OP, bool default_return_value>
38
  struct apply_op_if<OP,true,default_return_value>
39
  {
40
    template<typename T1, typename T2>
41
26568
    static bool op(const T1 & a, const T2 & b)
42
    {
43
26568
      return OP::call(a,b);
44
    }
45
  };
46
}
47
48
#endif //#ifndef __pinocchio_math_comparison_operators_hpp__
49