summaryrefslogtreecommitdiff
path: root/asl/utility.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/utility.hpp')
-rw-r--r--asl/utility.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/asl/utility.hpp b/asl/utility.hpp
index 4f27017..6a43852 100644
--- a/asl/utility.hpp
+++ b/asl/utility.hpp
@@ -37,11 +37,17 @@ constexpr U bit_cast(T value) requires (size_of<T> == size_of<U>)
}
template<typename T>
-T min(T a, T b)
+constexpr T min(T a, T b)
{
return (a <= b) ? a : b;
}
+template<typename T>
+constexpr T max(T a, T b)
+{
+ return (a >= b) ? a : b;
+}
+
constexpr uint64_t round_up_pow2(uint64_t v)
{
ASL_ASSERT(v <= 0x8000'0000'0000'0000);
@@ -58,6 +64,11 @@ constexpr uint64_t round_up_pow2(uint64_t v)
return v + 1;
}
+constexpr bool is_pow2(isize_t v)
+{
+ return v > 0 && ((v - 1) & v) == 0;
+}
+
#define ASL_DELETE_COPY(T) \
T(const T&) = delete; \
T& operator=(const T&) = delete;