* @brief Rounds @a value up to the next power of two (>= 2). Used by FixedQueue * to size its backing storage so wrap-around can mask with `& (cap-1)`. */
| 51 | * to size its backing storage so wrap-around can mask with `& (cap-1)`. |
| 52 | */ |
| 53 | [[nodiscard]] inline std::size_t roundUpToPowerOfTwo(std::size_t value) noexcept |
| 54 | { |
| 55 | std::size_t v = value < 2 ? 2 : value; |
| 56 | --v; |
| 57 | v |= v >> 1; |
| 58 | v |= v >> 2; |
| 59 | v |= v >> 4; |
| 60 | v |= v >> 8; |
| 61 | v |= v >> 16; |
| 62 | if constexpr (sizeof(std::size_t) > 4) |
| 63 | v |= v >> 32; |
| 64 | return v + 1; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @brief A fixed-capacity, auto-overwriting circular buffer (FIFO queue) with pow2 storage. |
no outgoing calls
no test coverage detected