@@ -176,19 +176,22 @@ struct MathConstants
176176 static_assert (std::is_floating_point_v<FloatType>, " FloatType can only be a floating point type." );
177177
178178 /* * A predefined value for Pi */
179- static constexpr FloatType pi = static_cast <FloatType> (3 .141592653589793238L );
179+ static inline constexpr FloatType pi = static_cast <FloatType> (3 .141592653589793238L );
180180
181181 /* * A predefined value for 2 * Pi */
182- static constexpr FloatType twoPi = static_cast <FloatType> (2 .0L * 3 .141592653589793238L );
182+ static inline constexpr FloatType twoPi = static_cast <FloatType> (2 .0L * 3 .141592653589793238L );
183183
184184 /* * A predefined value for Pi / 2 */
185- static constexpr FloatType halfPi = static_cast <FloatType> (3 .141592653589793238L / 2 .0L );
185+ static inline constexpr FloatType halfPi = static_cast <FloatType> (3 .141592653589793238L / 2 .0L );
186186
187187 /* * A predefined value for Euler's number */
188- static constexpr FloatType euler = static_cast <FloatType> (2 .71828182845904523536L );
188+ static inline constexpr FloatType euler = static_cast <FloatType> (2 .71828182845904523536L );
189189
190190 /* * A predefined value for sqrt (2) */
191- static constexpr FloatType sqrt2 = static_cast <FloatType> (1 .4142135623730950488L );
191+ static inline constexpr FloatType sqrt2 = static_cast <FloatType> (1 .4142135623730950488L );
192+
193+ /* * A predefined value for 0.5 */
194+ static inline constexpr FloatType half = static_cast <FloatType> (0 .5L );
192195};
193196
194197/* * Converts an angle in degrees to radians. */
@@ -630,11 +633,14 @@ constexpr bool isWithin (Type a, Type b, Type tolerance) noexcept
630633 even numbers will be rounded up or down differently.
631634*/
632635template <typename FloatType>
633- constexpr int roundToInt (const FloatType value) noexcept
636+ constexpr auto roundToInt (const FloatType value) noexcept
637+ -> std::enable_if_t<std::is_floating_point_v<FloatType>, int>
634638{
635639 if (isConstantEvaluated ())
636640 {
637- return static_cast <int > (value > FloatType (0 ) ? value + FloatType (0.5 ) : value - FloatType (0.5 ));
641+ return static_cast <int > (value > 0
642+ ? value + MathConstants<FloatType>::half
643+ : value - MathConstants<FloatType>::half);
638644 }
639645 else
640646 {
0 commit comments