|
|
@@ -10,18 +10,18 @@
|
|
|
namespace bx
|
|
|
{
|
|
|
template<bool>
|
|
|
- inline bool isEnabled()
|
|
|
+ inline constexpr bool isEnabled()
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
- inline bool isEnabled<false>()
|
|
|
+ inline constexpr bool isEnabled<false>()
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- inline bool ignoreC4127(bool _x)
|
|
|
+ inline constexpr bool ignoreC4127(bool _x)
|
|
|
{
|
|
|
return _x;
|
|
|
}
|
|
|
@@ -33,39 +33,45 @@ namespace bx
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty min(const Ty& _a, const Ty& _b)
|
|
|
+ inline constexpr Ty min(const Ty& _a, const Ty& _b)
|
|
|
{
|
|
|
return _a < _b ? _a : _b;
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty max(const Ty& _a, const Ty& _b)
|
|
|
+ inline constexpr Ty max(const Ty& _a, const Ty& _b)
|
|
|
{
|
|
|
return _a > _b ? _a : _b;
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty min(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
+ inline constexpr Ty min(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
{
|
|
|
return min(min(_a, _b), _c);
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty max(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
+ inline constexpr Ty max(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
{
|
|
|
return max(max(_a, _b), _c);
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty mid(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
+ inline constexpr Ty mid(const Ty& _a, const Ty& _b, const Ty& _c)
|
|
|
{
|
|
|
return max(min(_a, _b), min(max(_a, _b), _c) );
|
|
|
}
|
|
|
|
|
|
template<typename Ty>
|
|
|
- inline Ty clamp(const Ty& _a, const Ty& _min, const Ty& _max)
|
|
|
+ inline constexpr Ty clamp(const Ty& _a, const Ty& _min, const Ty& _max)
|
|
|
{
|
|
|
return max(min(_a, _max), _min);
|
|
|
}
|
|
|
|
|
|
+ template<typename Ty>
|
|
|
+ inline constexpr bool isPowerOf2(Ty _a)
|
|
|
+ {
|
|
|
+ return _a && !(_a & (_a - 1) );
|
|
|
+ }
|
|
|
+
|
|
|
} // namespace bx
|