mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 02:31:35 +08:00
Dependency on math.h and the last 'using namespace std' were removed
This commit is contained in:
@@ -16,9 +16,7 @@
|
|||||||
#ifndef UAVCAN_CPP_VERSION
|
#ifndef UAVCAN_CPP_VERSION
|
||||||
# error UAVCAN_CPP_VERSION
|
# error UAVCAN_CPP_VERSION
|
||||||
#endif
|
#endif
|
||||||
#if UAVCAN_CPP_VERSION < UAVCAN_CPP11
|
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||||
# include <math.h> // Needed for isfinite()
|
|
||||||
#else
|
|
||||||
# include <limits> // Assuming that in C++11 mode all standard headers are available
|
# include <limits> // Assuming that in C++11 mode all standard headers are available
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -169,8 +167,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static inline void saturate(StorageType& value)
|
static inline void saturate(StorageType& value)
|
||||||
{
|
{
|
||||||
using namespace std;
|
if ((IsExactRepresentation == 0) && isFinite(value))
|
||||||
if ((IsExactRepresentation == 0) && isfinite(value))
|
|
||||||
{
|
{
|
||||||
if (value > max())
|
if (value > max())
|
||||||
{
|
{
|
||||||
@@ -189,8 +186,7 @@ private:
|
|||||||
|
|
||||||
static inline void truncate(StorageType& value)
|
static inline void truncate(StorageType& value)
|
||||||
{
|
{
|
||||||
using namespace std;
|
if ((IsExactRepresentation == 0) && isFinite(value))
|
||||||
if ((IsExactRepresentation == 0) && isfinite(value))
|
|
||||||
{
|
{
|
||||||
if (value > max())
|
if (value > max())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -470,6 +470,20 @@ inline bool isInfinity(T arg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacement for std::isfinite().
|
||||||
|
* Note that direct float comparison (==, !=) is intentionally avoided.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline bool isFinite(T arg)
|
||||||
|
{
|
||||||
|
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||||
|
return std::isfinite(arg);
|
||||||
|
#else
|
||||||
|
return !isNaN(arg) && !isInfinity(arg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for std::signbit().
|
* Replacement for std::signbit().
|
||||||
* Note that direct float comparison (==, !=) is intentionally avoided.
|
* Note that direct float comparison (==, !=) is intentionally avoided.
|
||||||
|
|||||||
Reference in New Issue
Block a user