utils/static-if.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 INRIA
3 //
4 
5 #ifndef __pinocchio_utils_static_if_hpp__
6 #define __pinocchio_utils_static_if_hpp__
7 
8 #include "pinocchio/fwd.hpp"
9 
10 namespace pinocchio
11 {
12  namespace internal
13  {
14 
16 
17  template<typename LhsType, typename RhsType, typename ThenType, typename ElseType>
19 
21  template<typename LhsType, typename RhsType, typename return_type>
22  struct traits< if_then_else_impl<LhsType,RhsType,return_type,return_type> >
23  {
24  typedef return_type ReturnType;
25  };
26 
27  template<typename condition_type, typename ThenType, typename ElseType>
28  struct if_then_else_impl<condition_type,condition_type,ThenType,ElseType>
29  {
31 
32  static inline ReturnType run(const ComparisonOperators op,
33  const condition_type & lhs_value,
34  const condition_type & rhs_value,
35  const ThenType & then_value,
36  const ElseType & else_value)
37  {
38  switch(op)
39  {
40  case LT:
41  if(lhs_value < rhs_value)
42  return then_value;
43  else
44  return else_value;
45  break;
46  case LE:
47  if(lhs_value <= rhs_value)
48  return then_value;
49  else
50  return else_value;
51  break;
52  case EQ:
53  if(lhs_value == rhs_value)
54  return then_value;
55  else
56  return else_value;
57  break;
58  case GE:
59  if(lhs_value >= rhs_value)
60  return then_value;
61  else
62  return else_value;
63  break;
64  case GT:
65  if(lhs_value > rhs_value)
66  return then_value;
67  else
68  return else_value;
69  break;
70  }
71  abort();
72  }
73  };
74 
75  template<typename LhsType, typename RhsType, typename ThenType, typename ElseType>
78  const LhsType & lhs_value,
79  const RhsType & rhs_value,
80  const ThenType & then_value,
81  const ElseType & else_value)
82  {
84  return algo::run(op,
85  lhs_value,
86  rhs_value,
87  then_value,
88  else_value);
89  }
90 
91 
92 
93  } // namespace internal
94 } // namespace pinocchio
95 
96 #endif
Main pinocchio namespace.
Definition: timings.cpp:28
static ReturnType run(const ComparisonOperators op, const condition_type &lhs_value, const condition_type &rhs_value, const ThenType &then_value, const ElseType &else_value)
if_then_else_impl< LhsType, RhsType, ThenType, ElseType >::ReturnType if_then_else(const ComparisonOperators op, const LhsType &lhs_value, const RhsType &rhs_value, const ThenType &then_value, const ElseType &else_value)


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32