| Line |
Branch |
Exec |
Source |
| 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> |
| 17 |
|
|
struct check_expression_if_real_valued |
| 18 |
|
|
{ |
| 19 |
|
130 |
static bool run(const void *) |
| 20 |
|
|
{ |
| 21 |
|
130 |
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 |
|
737399 |
static bool run(const void * expression_ptr) |
| 29 |
|
|
{ |
| 30 |
|
737399 |
return *static_cast<const bool *>(expression_ptr); |
| 31 |
|
|
} |
| 32 |
|
|
}; |
| 33 |
|
|
|
| 34 |
|
|
template<typename Scalar, typename Any> |
| 35 |
|
354692 |
bool check_expression_if_real(const Any & expression) |
| 36 |
|
|
{ |
| 37 |
|
354692 |
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 |
|
186286 |
bool check_expression_if_real(const Any & expression) |
| 42 |
|
|
{ |
| 43 |
|
186286 |
return check_expression_if_real_valued<Scalar, default_value>::run( |
| 44 |
|
186286 |
static_cast<const void *>(&expression)); |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
} // namespace pinocchio |
| 48 |
|
|
|
| 49 |
|
|
#endif // ifndef __pinocchio_utils_check_hpp__ |
| 50 |
|
|
|