5#ifndef __pinocchio_utils_static_if_hpp__
6#define __pinocchio_utils_static_if_hpp__
8#include "pinocchio/fwd.hpp"
15 enum ComparisonOperators
24 template<
typename LhsType,
typename RhsType,
typename ThenType,
typename ElseType>
25 struct if_then_else_impl;
27 template<
typename LhsType,
typename RhsType>
28 struct comparison_eq_impl;
31 template<
typename LhsType,
typename RhsType,
typename return_type>
32 struct traits<if_then_else_impl<LhsType, RhsType, return_type, return_type>>
34 typedef return_type ReturnType;
37 template<
typename condition_type,
typename ThenType,
typename ElseType>
38 struct if_then_else_impl<condition_type, condition_type, ThenType, ElseType>
40 typedef typename internal::traits<if_then_else_impl>::ReturnType ReturnType;
42 static inline ReturnType run(
43 const ComparisonOperators op,
44 const condition_type & lhs_value,
45 const condition_type & rhs_value,
46 const ThenType & then_value,
47 const ElseType & else_value)
52 if (lhs_value == rhs_value)
58 if (lhs_value < rhs_value)
64 if (lhs_value <= rhs_value)
70 if (lhs_value >= rhs_value)
76 if (lhs_value > rhs_value)
82 PINOCCHIO_THROW_PRETTY(
83 std::logic_error,
"ComparisonOperators " <<
static_cast<int>(op) <<
" is not managed");
87 template<
typename LhsType,
typename RhsType,
typename ThenType,
typename ElseType>
88 inline typename if_then_else_impl<LhsType, RhsType, ThenType, ElseType>::ReturnType
90 const ComparisonOperators op,
91 const LhsType & lhs_value,
92 const RhsType & rhs_value,
93 const ThenType & then_value,
94 const ElseType & else_value)
96 typedef if_then_else_impl<LhsType, RhsType, ThenType, ElseType> algo;
97 return algo::run(op, lhs_value, rhs_value, then_value, else_value);
101 template<
typename LhsType,
typename RhsType>
102 struct comparison_eq_impl
104 static inline bool run(
const LhsType & lhs_value,
const RhsType & rhs_value)
106 return lhs_value == rhs_value;
110 template<
typename condition_type>
111 struct comparison_eq_impl<condition_type, condition_type>
113 static inline bool run(
const condition_type & lhs_value,
const condition_type & rhs_value)
115 return lhs_value == rhs_value;
119 template<
typename LhsType,
typename RhsType>
120 inline bool comparison_eq(
const LhsType & lhs_value,
const RhsType & rhs_value)
122 typedef comparison_eq_impl<LhsType, RhsType> algo;
123 return algo::run(lhs_value, rhs_value);
Main pinocchio namespace.