Function fast_mod
Synopsis
#include <src/entt/core/memory.hpp>
constexpr std::size_t fast_mod(const std::size_t value, const std::size_t mod)
Description
Fast module utility function (powers of two only).
- Parameters
value
- A value for which to calculate the modulus.mod
- Modulus, it must be a power of two.- Returns
- The common remainder.
Mentioned in
- Core Functionalities / Power of two and fast modulus
Source
Lines 102-105 in src/entt/core/memory.hpp.
[[nodiscard]] inline constexpr std::size_t fast_mod(const std::size_t value, const std::size_t mod) ENTT_NOEXCEPT {
ENTT_ASSERT(is_power_of_two(mod), "Value must be a power of two");
return value & (mod - 1u);
}