mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 01:41:37 +08:00
mathlib : switch min/max to constexpr to match std::min/max
This commit is contained in:
committed by
Kabir Mohammed
parent
9909a373b0
commit
c8dad56300
@@ -56,19 +56,19 @@ namespace math
|
|||||||
{
|
{
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline const _Tp &min(const _Tp &a, const _Tp &b)
|
inline constexpr const _Tp &min(const _Tp &a, const _Tp &b)
|
||||||
{
|
{
|
||||||
return (a < b) ? a : b;
|
return (a < b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline const _Tp &max(const _Tp &a, const _Tp &b)
|
inline constexpr const _Tp &max(const _Tp &a, const _Tp &b)
|
||||||
{
|
{
|
||||||
return (a > b) ? a : b;
|
return (a > b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline const _Tp &constrain(const _Tp &val, const _Tp &min_val, const _Tp &max_val)
|
inline constexpr const _Tp &constrain(const _Tp &val, const _Tp &min_val, const _Tp &max_val)
|
||||||
{
|
{
|
||||||
return (val < min_val) ? min_val : ((val > max_val) ? max_val : val);
|
return (val < min_val) ? min_val : ((val > max_val) ? max_val : val);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user