summaryrefslogtreecommitdiff
path: root/asl/utility.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-12 00:17:02 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commit7c9e871eb66de64e7a1861fd1faebcd5524fed96 (patch)
tree63bfcf8a2163c724b39e67f3786f0daab94a8ea1 /asl/utility.hpp
parentb509ebcdc5858a88af4b23499a964305da484b8d (diff)
Add reserve_capacity to buffer
Diffstat (limited to 'asl/utility.hpp')
-rw-r--r--asl/utility.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/asl/utility.hpp b/asl/utility.hpp
index 7740eff..451a1e3 100644
--- a/asl/utility.hpp
+++ b/asl/utility.hpp
@@ -2,6 +2,7 @@
#include "asl/meta.hpp"
#include "asl/layout.hpp"
+#include "asl/assert.hpp"
#define ASL_MOVE(expr_) (static_cast<::asl::un_ref_t<decltype(expr_)>&&>(expr_))
@@ -30,6 +31,22 @@ T min(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);
+
+ v -= 1;
+
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v |= v >> 32;
+
+ return v + 1;
+}
+
#define ASL_DELETE_COPY(T) \
T(const T&) = delete; \
T& operator=(const T&) = delete;