Created
August 8, 2021 14:09
-
-
Save ryutorion/c32c7307ede0caf57d42ea61975a9fff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UTILITY_H_INCLUDED | |
#define UTILITY_H_INCLUDED | |
#include <cstdint> | |
#include <bit> | |
template <uint64_t N> | |
[[nodiscard]] | |
constexpr uint64_t multipleof(const uint64_t value) noexcept | |
{ | |
static_assert(std::popcount(N) == 1); | |
return (value + N - 1) & ~(N - 1); | |
} | |
#endif // UTILITY_H_INCLUDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment