pinocchio  3.2.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
check.hpp
1 //
2 // Copyright (c) 2020 INRIA
3 //
4 
5 #ifndef __pinocchio_utils_check_hpp__
6 #define __pinocchio_utils_check_hpp__
7 
8 #include <boost/type_traits/is_floating_point.hpp>
9 
10 namespace pinocchio
11 {
12 
13  template<
14  typename Scalar,
15  bool default_value = true,
16  bool is_real_valued = boost::is_floating_point<Scalar>::value>
18  {
19  static bool run(const void *)
20  {
21  return default_value;
22  }
23  };
24 
25  template<typename Scalar, bool default_value>
26  struct check_expression_if_real_valued<Scalar, default_value, true>
27  {
28  static bool run(const void * expression_ptr)
29  {
30  return *static_cast<const bool *>(expression_ptr);
31  }
32  };
33 
34  template<typename Scalar, typename Any>
35  bool check_expression_if_real(const Any & expression)
36  {
37  return check_expression_if_real_valued<Scalar>::run(static_cast<const void *>(&expression));
38  }
39 
40  template<typename Scalar, bool default_value, typename Any>
41  bool check_expression_if_real(const Any & expression)
42  {
43  return check_expression_if_real_valued<Scalar, default_value>::run(
44  static_cast<const void *>(&expression));
45  }
46 
47 } // namespace pinocchio
48 
49 #endif // ifndef __pinocchio_utils_check_hpp__
Main pinocchio namespace.
Definition: treeview.dox:11