We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c6da990 commit 26804c0Copy full SHA for 26804c0
1 file changed
core/foundation/inc/ROOT/BitUtils.hxx
@@ -15,6 +15,7 @@
15
#include <algorithm>
16
#include <cassert>
17
#include <cstddef>
18
+#include <cstdint>
19
#include <type_traits>
20
21
#ifdef _MSC_VER
@@ -24,12 +25,17 @@
24
25
namespace ROOT {
26
namespace Internal {
27
28
+inline bool IsPowerOfTwo(std::uint64_t v)
29
+{
30
+ return (v & (v - 1)) == 0;
31
+}
32
+
33
/// Return true if \p align is a valid C++ alignment value: strictly positive
34
/// and a power of two. This is the set of values accepted by
35
/// `::operator new[](n, std::align_val_t(align))`.
36
inline constexpr bool IsValidAlignment(std::size_t align) noexcept
37
{
- return align > 0 && (align & (align - 1)) == 0;
38
+ return align > 0 && IsPowerOfTwo(align);
39
}
40
41
/// Round \p value up to the next multiple of \p align.
0 commit comments