\hypertarget{bits_8h}{}\doxysection{kblib/bits.h File Reference}
\label{bits_8h}\index{kblib/bits.h@{kblib/bits.h}}


Provides bit-\/manipulation functions and classes.  


{\ttfamily \#include $<$algorithm$>$}\newline
{\ttfamily \#include $<$array$>$}\newline
{\ttfamily \#include $<$bitset$>$}\newline
{\ttfamily \#include $<$limits$>$}\newline
{\ttfamily \#include $<$memory$>$}\newline
{\ttfamily \#include $<$utility$>$}\newline
{\ttfamily \#include $<$vector$>$}\newline
{\ttfamily \#include $<$iostream$>$}\newline
{\ttfamily \#include \char`\"{}fakestd.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}simple.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}stats.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}tdecl.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}traits.\+h\char`\"{}}\newline
Include dependency graph for bits.\+h\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{bits_8h__incl}
\end{center}
\end{figure}
This graph shows which files directly or indirectly include this file\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{bits_8h__dep__incl}
\end{center}
\end{figure}
\doxysubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \mbox{\hyperlink{classkblib_1_1detail__bits_1_1trie__node}{kblib\+::detail\+\_\+bits\+::trie\+\_\+node$<$ Key, Value $>$}}
\item 
class \mbox{\hyperlink{classkblib_1_1compact__bit__trie}{kblib\+::compact\+\_\+bit\+\_\+trie$<$ Key, key\+\_\+range, Value $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1compact__bit__trie_1_1key__type}{kblib\+::compact\+\_\+bit\+\_\+trie$<$ Key, key\+\_\+range, Value $>$\+::key\+\_\+type}}
\item 
class \mbox{\hyperlink{classkblib_1_1compact__bit__trie_1_1iterator__t}{kblib\+::compact\+\_\+bit\+\_\+trie$<$ Key, key\+\_\+range, Value $>$\+::iterator\+\_\+t$<$ V $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1bitfield}{kblib\+::bitfield$<$ offset, size, Storage $>$}}
\begin{DoxyCompactList}\small\item\em Implements a bitfield abstraction. May be used in a union with other bitfields. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1bitfield__proxy}{kblib\+::detail\+\_\+bits\+::bitfield\+\_\+proxy$<$ Parent, Return\+T, Set, Get $>$}}
\begin{DoxyCompactList}\small\item\em A proxy reference type for BITFIELD-\/declared bitfields. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1pun__proxy}{kblib\+::detail\+\_\+bits\+::pun\+\_\+proxy$<$ Type, Storage $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__pun__proxy}{kblib\+::detail\+\_\+bits\+::array\+\_\+pun\+\_\+proxy$<$ Type, Storage $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter$<$ T $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter_3_01_t_0f_n_0e_4}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter$<$ T\mbox{[}\+N\mbox{]}$>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter_3_01_t_0f_0e_4}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter$<$ T\mbox{[}$\,$\mbox{]}$>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter2}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter2$<$ T, S $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter2_3_01_t_0f_n_0e_00_01_s_01_4}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter2$<$ T\mbox{[}\+N\mbox{]}, S $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1array__filter2_3_01_t_0f_0e_00_01_s_01_4}{kblib\+::detail\+\_\+bits\+::array\+\_\+filter2$<$ T\mbox{[}$\,$\mbox{]}, S $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1pun__el}{kblib\+::detail\+\_\+bits\+::pun\+\_\+el$<$ P, Type, S, size\+\_\+t, aliases $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1pun__el_3_01_p_00_01_type_0f_s_0e_00_01_s_00_01_i_00_01true_01_4}{kblib\+::detail\+\_\+bits\+::pun\+\_\+el$<$ P, Type\mbox{[}\+S\mbox{]}, S, I, true $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1pun__el_3_01_p_00_01_type_0f_0e_00_01_s_00_01_i_00_01true_01_4}{kblib\+::detail\+\_\+bits\+::pun\+\_\+el$<$ P, Type\mbox{[}$\,$\mbox{]}, S, I, true $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1detail__bits_1_1punner__impl_3_01_s_00_01std_1_1index__sequence_3_01_is_8_8_8_01_4_00_01_types_8_8_8_01_4}{kblib\+::detail\+\_\+bits\+::punner\+\_\+impl$<$ S, std\+::index\+\_\+sequence$<$ Is... $>$, Types... $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1punner}{kblib\+::punner$<$ Types $>$}}
\item 
struct \mbox{\hyperlink{structstd_1_1tuple__element_3_01_i_00_01kblib_1_1punner_3_01_types_8_8_8_01_4_01_4}{std\+::tuple\+\_\+element$<$ I, kblib\+::punner$<$ Types... $>$ $>$}}
\item 
struct \mbox{\hyperlink{structstd_1_1tuple__size_3_01kblib_1_1punner_3_01_types_8_8_8_01_4_01_4}{std\+::tuple\+\_\+size$<$ kblib\+::punner$<$ Types... $>$ $>$}}
\item 
class \mbox{\hyperlink{classkblib_1_1union__pun}{kblib\+::union\+\_\+pun$<$ Type, Storage $>$}}
\item 
class \mbox{\hyperlink{classkblib_1_1union__pun_3_01_type_0f_n_0e_00_01_storage_01_4}{kblib\+::union\+\_\+pun$<$ Type\mbox{[}\+N\mbox{]}, Storage $>$}}
\end{DoxyCompactItemize}
\doxysubsection*{Namespaces}
\begin{DoxyCompactItemize}
\item 
namespace \mbox{\hyperlink{namespacekblib}{kblib}}
\begin{DoxyCompactList}\small\item\em The main namespace in which all entities from kblib are defined. \end{DoxyCompactList}\item 
namespace \mbox{\hyperlink{namespacekblib_1_1detail__bits}{kblib\+::detail\+\_\+bits}}
\item 
namespace \mbox{\hyperlink{namespacestd}{std}}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}{KBLIB\+\_\+\+INTERNAL\+\_\+\+BITFIELD\+\_\+\+MACRO}}(offset,  size,  name,  raw)
\item 
\#define \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(offset,  size,  name,  raw)~ \mbox{\hyperlink{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}{KBLIB\+\_\+\+INTERNAL\+\_\+\+BITFIELD\+\_\+\+MACRO}}(offset, size, name, raw)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
constexpr auto \mbox{\hyperlink{namespacekblib_a240472ec40bbae42961817f5985de54e}{kblib\+::memswap}} (unsigned char $\ast$A, unsigned char $\ast$B, std\+::size\+\_\+t size) noexcept -\/$>$ void
\begin{DoxyCompactList}\small\item\em Swaps memory ranges. \end{DoxyCompactList}\item 
auto \mbox{\hyperlink{namespacekblib_a325b7ea3dc60a54c9b341e7851f94bcb}{kblib\+::memswap}} (void $\ast$A, void $\ast$B, std\+::size\+\_\+t size) noexcept -\/$>$ void
\begin{DoxyCompactList}\small\item\em Swaps memory ranges. \end{DoxyCompactList}\item 
{\footnotesize template$<$std\+::size\+\_\+t I, typename... Types$>$ }\\auto \mbox{\hyperlink{namespacekblib_a951945f1ed7d42562a7e6fa8cf8f0405}{kblib\+::get}} (\mbox{\hyperlink{unionpunner}{punner}}$<$ Types... $>$ \&p) noexcept -\/$>$ decltype(auto)
\item 
{\footnotesize template$<$std\+::size\+\_\+t I, typename... Types$>$ }\\auto \mbox{\hyperlink{namespacekblib_ac224d3445c7dba280beacefc67b7641b}{kblib\+::get}} (const \mbox{\hyperlink{unionpunner}{punner}}$<$ Types... $>$ \&p) noexcept -\/$>$ decltype(auto)
\item 
{\footnotesize template$<$std\+::size\+\_\+t I, typename... Types$>$ }\\auto \mbox{\hyperlink{namespacekblib_aeb5bc5882b32685b477723ff9b5d4642}{kblib\+::get}} (\mbox{\hyperlink{unionpunner}{punner}}$<$ Types... $>$ \&\&p) noexcept -\/$>$ decltype(auto)
\item 
{\footnotesize template$<$std\+::size\+\_\+t I, typename... Types$>$ }\\auto \mbox{\hyperlink{namespacekblib_af291a0ebb9263d6588279eb0e379abc1}{kblib\+::get}} (const \mbox{\hyperlink{unionpunner}{punner}}$<$ Types... $>$ \&\&p) noexcept -\/$>$ decltype(auto)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Int $>$ }\\constexpr int \mbox{\hyperlink{namespacekblib_aa29cd1999efff7dd9b8d9aa8ab468109}{kblib\+::bits\+\_\+of}} = std\+::numeric\+\_\+limits$<$Int$>$\+::digits
\item 
{\footnotesize template$<$typename... Types$>$ }\\constexpr std\+::size\+\_\+t \mbox{\hyperlink{namespacekblib_1_1detail__bits_a1666832c0507e41b9943583f1c67938d}{kblib\+::detail\+\_\+bits\+::max\+\_\+size}} = std\+::max(\{sizeof(typename array\+\_\+filter$<$Types$>$\+::type)...\})
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Provides bit-\/manipulation functions and classes. 

\begin{DoxyAuthor}{Author}
killerbee 
\end{DoxyAuthor}
\begin{DoxyDate}{Date}
2019-\/2021 
\end{DoxyDate}
\begin{DoxyCopyright}{Copyright}
GNU General Public Licence v3.\+0 
\end{DoxyCopyright}


Definition in file \mbox{\hyperlink{bits_8h_source}{bits.\+h}}.



\doxysubsection{Macro Definition Documentation}
\mbox{\Hypertarget{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}\label{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}} 
\index{bits.h@{bits.h}!BITFIELD@{BITFIELD}}
\index{BITFIELD@{BITFIELD}!bits.h@{bits.h}}
\doxysubsubsection{\texorpdfstring{BITFIELD}{BITFIELD}}
{\footnotesize\ttfamily \#define BITFIELD(\begin{DoxyParamCaption}\item[{}]{offset,  }\item[{}]{size,  }\item[{}]{name,  }\item[{}]{raw }\end{DoxyParamCaption})~ \mbox{\hyperlink{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}{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.

\begin{DoxyNote}{Note}
This macro is only defined if KBLIB\+\_\+\+DEF\+\_\+\+MACROS is true. 

This macro always declares the member functions publically.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
See \mbox{\hyperlink{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}{KBLIB\+\_\+\+INTERNAL\+\_\+\+BITFIELD\+\_\+\+MACRO}} for definition.
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em offset} & The number of bits less significant than this bitfield. \\
\hline
{\em size} & The number of bits in this bitfield. \\
\hline
{\em name} & The name of the generated member functions which operate on this bitfield. \\
\hline
{\em raw} & The name of the member variable in which the bitfield is stored. \\
\hline
\end{DoxyParams}


Definition at line \mbox{\hyperlink{bits_8h_source_l00863}{863}} of file \mbox{\hyperlink{bits_8h_source}{bits.\+h}}.

\mbox{\Hypertarget{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}\label{bits_8h_ae6ae7d7c5a7d3a7ea2f7b94678ec3e1b}} 
\index{bits.h@{bits.h}!KBLIB\_INTERNAL\_BITFIELD\_MACRO@{KBLIB\_INTERNAL\_BITFIELD\_MACRO}}
\index{KBLIB\_INTERNAL\_BITFIELD\_MACRO@{KBLIB\_INTERNAL\_BITFIELD\_MACRO}!bits.h@{bits.h}}
\doxysubsubsection{\texorpdfstring{KBLIB\_INTERNAL\_BITFIELD\_MACRO}{KBLIB\_INTERNAL\_BITFIELD\_MACRO}}
{\footnotesize\ttfamily \#define KBLIB\+\_\+\+INTERNAL\+\_\+\+BITFIELD\+\_\+\+MACRO(\begin{DoxyParamCaption}\item[{}]{offset,  }\item[{}]{size,  }\item[{}]{name,  }\item[{}]{raw }\end{DoxyParamCaption})}

\begin{DoxySeeAlso}{See also}
See \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD(offset, size, name, raw)}} for documentation. 
\end{DoxySeeAlso}
\begin{DoxyNote}{Note}
This macro is defined unconditionally. 

This macro resets the access level to public\+: 
\end{DoxyNote}


Definition at line \mbox{\hyperlink{bits_8h_source_l00491}{491}} of file \mbox{\hyperlink{bits_8h_source}{bits.\+h}}.

