From 87b580a72a2470cd2769aa14af601839fa710684 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 --- deps/ox/src/ox/std/bitops.hpp | 2 +- deps/ox/src/ox/std/types.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/deps/ox/src/ox/std/bitops.hpp b/deps/ox/src/ox/std/bitops.hpp index 8a2956af..2b9fd1db 100644 --- a/deps/ox/src/ox/std/bitops.hpp +++ b/deps/ox/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/deps/ox/src/ox/std/types.hpp b/deps/ox/src/ox/std/types.hpp index 1bab5c16..44fb987d 100644 --- a/deps/ox/src/ox/std/types.hpp +++ b/deps/ox/src/ox/std/types.hpp @@ -51,6 +51,13 @@ typedef uint32_t uintptr_t; #endif +namespace ox { + +template +constexpr auto MaxValue = onMask(); + +} + namespace std {