EnTT 4.0.0
Loading...
Searching...
No Matches
bit.hpp
1#ifndef ENTT_CORE_BIT_HPP
2#define ENTT_CORE_BIT_HPP
3
4#include "../config/config.h"
5#include "../stl/bit.hpp"
6#include "../stl/concepts.hpp"
7#include "../stl/cstddef.hpp"
8
9namespace entt {
10
18template<stl::unsigned_integral Type>
19[[nodiscard]] constexpr Type fast_mod(const Type value, const stl::size_t mod) noexcept {
20 ENTT_ASSERT_CONSTEXPR(stl::has_single_bit(mod), "Value must be a power of two");
21 return static_cast<Type>(value & (mod - 1u));
22}
23
24} // namespace entt
25
26#endif
EnTT default namespace.
Definition dense_map.hpp:25
constexpr Type fast_mod(const Type value, const stl::size_t mod) noexcept
Fast module utility function (powers of two only).
Definition bit.hpp:19