Skip to content
Snippets Groups Projects
Commit 30bb2197 authored by Uwe Woessner's avatar Uwe Woessner
Browse files

std::abs is not constexpr in MSVC

thus I added myAbs which is constexpr and should compile with both gcc and MSVC
parent 8e030bd6
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@
#include <vector>
#include "math.h"
#include "common/globalDefinitions.h"
//-----------------------------------------------------------------------------
//! @brief defines common helper functions like conversion from and to enums.
......@@ -25,7 +26,7 @@ static constexpr double EPSILON = 0.001; //!Treat values smaller than epsilon as
[[maybe_unused]] static inline constexpr bool DoubleEquality(double value1, double value2, double epsilon = EPSILON)
{
return std::abs(value1 - value2) <= epsilon;
return myAbs(value1 - value2) <= epsilon;
}
//! Returns the same angle but within the range [-PI, PI]
......
......@@ -24,6 +24,7 @@
#include <string>
#include <tuple>
#include <vector>
#include <array>
// the following is a temporary workaround until the contribution is merged into osi
#if defined(_WIN32) && !defined(NODLL)
......@@ -39,6 +40,11 @@
#define OSIEXPORT
#endif
inline constexpr double myAbs(double a) noexcept
{
return (a >= 0) ? a : -a;
}
#if defined(open_simulation_interface_EXPORTS)
#define OSI_EXPORT OSIEXPORT
#else
......
......@@ -17,6 +17,7 @@
#include <ostream>
#include <cmath>
#include "common/opExport.h"
#include "common/globalDefinitions.h"
namespace Common {
......@@ -196,6 +197,7 @@ public:
return Vector2d(x * in, y * in);
}
/*!
* \brief Comparison operator taking EPSILON of 1e-9 into account
*
......@@ -205,8 +207,8 @@ public:
*/
constexpr bool operator==(const Vector2d &in) const noexcept
{
return (std::abs(x - in.x) < EPSILON) &&
(std::abs(y - in.y) < EPSILON);
return (myAbs(x - in.x) < EPSILON) &&
(myAbs(y - in.y) < EPSILON);
}
/*!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment