|
kblib 0.2.3
General utilities library for modern C++
|
Provides bit-manipulation functions and classes. More...
#include <algorithm>#include <array>#include <bitset>#include <limits>#include <memory>#include <utility>#include <vector>#include "fakestd.h"#include "simple.h"#include "stats.h"#include "tdecl.h"#include "traits.h"

Go to the source code of this file.
Namespaces | |
| namespace | kblib |
| The main namespace in which all entities from kblib are defined. | |
| namespace | kblib::detail_bits |
| namespace | std |
Macros | |
| #define | KBLIB_INTERNAL_BITFIELD_MACRO(offset, size, name, raw) |
| #define | BITFIELD(offset, size, name, raw) KBLIB_INTERNAL_BITFIELD_MACRO(offset, size, name, raw) |
Functions | |
| constexpr auto | kblib::memswap (unsigned char *A, unsigned char *B, std::size_t size) noexcept -> void |
| Swaps memory ranges. More... | |
| auto | kblib::memswap (void *A, void *B, std::size_t size) noexcept -> void |
| Swaps memory ranges. More... | |
| template<std::size_t I, typename... Types> | |
| auto | kblib::get (punner< Types... > &p) noexcept -> decltype(auto) |
| template<std::size_t I, typename... Types> | |
| auto | kblib::get (const punner< Types... > &p) noexcept -> decltype(auto) |
| template<std::size_t I, typename... Types> | |
| auto | kblib::get (punner< Types... > &&p) noexcept -> decltype(auto) |
| template<std::size_t I, typename... Types> | |
| auto | kblib::get (const punner< Types... > &&p) noexcept -> decltype(auto) |
Variables | |
| template<typename Int > | |
| constexpr int | kblib::bits_of = std::numeric_limits<Int>::digits |
| template<typename... Types> | |
| constexpr std::size_t | kblib::detail_bits::max_size = std::max({sizeof(typename array_filter<Types>::type)...}) |
Provides bit-manipulation functions and classes.
Definition in file bits.h.
| #define BITFIELD | ( | offset, | |
| size, | |||
| name, | |||
| raw | |||
| ) | KBLIB_INTERNAL_BITFIELD_MACRO(offset, size, name, raw) |
Defines appropriate member functions which operate on a bitfield. The generated functions are constexpr and optimize well.
Declare inside a struct to add a simulated bitfield to it. In total, 5 member functions will be defined, three of which are public. (The private two are required only to get around overload resolution problems with the proxy reference type.)
One is a const accessor, which returns the value of the field. One is a setter, which takes a new value for the field and assigns it, then returns the new value (after truncating it to the field width). The last function is the non-const accessor, which takes no argument and returns a proxy reference to the bitfield, which may be assigned to or implicitly converted to the value type.
| offset | The number of bits less significant than this bitfield. |
| size | The number of bits in this bitfield. |
| name | The name of the generated member functions which operate on this bitfield. |
| raw | The name of the member variable in which the bitfield is stored. |
| #define KBLIB_INTERNAL_BITFIELD_MACRO | ( | offset, | |
| size, | |||
| name, | |||
| raw | |||
| ) |