summaryrefslogtreecommitdiff
path: root/asl/utility.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-14 00:01:55 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-14 00:02:02 +0100
commit1c00f6ed444dab15430a955e41cf155049e3cec4 (patch)
tree1be0c44df0e102dfa577f4c11abc56ef4fe57bcc /asl/utility.hpp
parent5d6e9aac39551db657df5f48ae2baa7b77c5c093 (diff)
Start work on hash_set
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;