pinocchio  2.4.0-dirty
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
static-if.hpp
1 //
2 // Copyright (c) 2019 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 
15  template<typename if_type, typename then_type, typename else_type>
16  struct if_then_else_impl;
17 
18  template<typename if_type, typename same_then_and_else_type>
19  struct traits<if_then_else_impl<if_type,same_then_and_else_type,same_then_and_else_type> >
20  {
21  typedef same_then_and_else_type ReturnType;
22  };
23 
24  template<typename then_type, typename else_type>
25  struct if_then_else_impl<bool,then_type,else_type>
26  {
27  typedef typename internal::traits<if_then_else_impl>::ReturnType ReturnType;
28 
29  static inline ReturnType run(bool condition,
30  const then_type & then_value,
31  const else_type & else_value)
32  {
33  if(condition)
34  return then_value;
35  else
36  return else_value;
37  }
38  };
39 
40  template<typename if_type, typename then_type, typename else_type>
41  inline typename if_then_else_impl<if_type,then_type,else_type>::ReturnType
42  if_then_else(const if_type & condition,
43  const then_type & then_value,
44  const else_type & else_value)
45  {
46  return if_then_else_impl<if_type,then_type,else_type>::run(condition,
47  then_value,
48  else_value);
49  }
50 
51 
52 
53  } // namespace internal
54 } // namespace pinocchio
55 
56 #endif
Main pinocchio namespace.
Definition: treeview.dox:24