![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include "lib/code_annotation.h"#include "lib/debug.h"#include "lib/status.h"#include <bit>#include <climits>#include <cstddef>#include <limits>#include <type_traits>

Go to the source code of this file.
Macros | |
| #define | BIT(n) (1u << (n)) |
| pretty much the same as Bit<unsigned>. More... | |
| #define | ROUND_UP(n, multiple) (((n) + (multiple)-1) & ~((multiple)-1)) |
Functions | |
| template<typename T > | |
| T | Bit (size_t n) |
| value of bit number <n>. More... | |
| template<typename T > | |
| bool | IsBitSet (T value, size_t index) |
| template<typename T > | |
| T | bit_mask (size_t numBits) |
| a mask that includes the lowest N bits More... | |
| template<typename T > | |
| T | bits (T num, size_t lo_idx, size_t hi_idx) |
| extract the value of bits hi_idx:lo_idx within num More... | |
| template<typename T > | |
| T | round_up (T n, T multiple) |
| round number up/down to the next given multiple. More... | |
| template<typename T > | |
| T | round_down (T n, T multiple) |
| #define BIT | ( | n | ) | (1u << (n)) |
pretty much the same as Bit<unsigned>.
this is intended for the initialization of enum values, where a compile-time constant is required.
| #define ROUND_UP | ( | n, | |
| multiple | |||
| ) | (((n) + (multiple)-1) & ~((multiple)-1)) |
value of bit number <n>.
| n | bit index. |
requirements:
a mask that includes the lowest N bits
| numBits | Number of bits in mask. |
extract the value of bits hi_idx:lo_idx within num
example: bits(0x69, 2, 5) == 0x0A
| num | number whose bits are to be extracted |
| lo_idx | bit index of lowest bit to include |
| hi_idx | bit index of highest bit to include |