From 854d46ea77e582a17b5817d1e98acfb28b2a7da5 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 7 Jul 2018 14:36:27 -0500 Subject: [PATCH] [ox/std] Add MaxValue constexpr template (synced from 87b580a72a2470cd2769aa14af601839fa710684) --- src/ox/std/bitops.hpp | 2 +- src/ox/std/types.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ox/std/bitops.hpp b/src/ox/std/bitops.hpp index 8a2956afe..2b9fd1db7 100644 --- a/src/ox/std/bitops.hpp +++ b/src/ox/std/bitops.hpp @@ -17,7 +17,7 @@ inline constexpr T rotateLeft(T i, int shift) { } template -constexpr T onMask(int bits) { +constexpr T onMask(int bits = sizeof(T)) { T out = 0; for (auto i = 0; i < bits; i++) { out |= static_cast(1) << i; diff --git a/src/ox/std/types.hpp b/src/ox/std/types.hpp index 1bab5c165..44fb987de 100644 --- a/src/ox/std/types.hpp +++ b/src/ox/std/types.hpp @@ -51,6 +51,13 @@ typedef uint32_t uintptr_t; #endif +namespace ox { + +template +constexpr auto MaxValue = onMask(); + +} + namespace std {