\hypertarget{bits_8cpp_source}{}\doxysection{bits.\+cpp} \label{bits_8cpp_source}\index{tests/bits.cpp@{tests/bits.cpp}} \mbox{\hyperlink{bits_8cpp}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00001}\mbox{\hyperlink{bits_8cpp_a9311c51550d8fac774a907be5e22fca1}{00001}} \textcolor{preprocessor}{\#define KBLIB\_DEF\_MACROS 1}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00002}00002 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{bits_8h}{kblib/bits.h}}"{}}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00003}00003 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00004}00004 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{hash_8h}{kblib/hash.h}}"{}}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00005}00005 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00006}00006 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00007}00007 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00008}00008 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00009}\mbox{\hyperlink{structprint}{00009}} \textcolor{keyword}{struct }\mbox{\hyperlink{structprint}{print}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00010}00010 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00011}00011 \textcolor{comment}{// These tests are POSIX-\/based, so spell out that requirement.}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00012}00012 \textcolor{keyword}{static\_assert}(CHAR\_BIT == 8, \textcolor{stringliteral}{"{}8-\/bit bytes"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00013}00013 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(short) == 2, \textcolor{stringliteral}{"{}16-\/bit shorts"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00014}00014 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(int) == 4, \textcolor{stringliteral}{"{}32-\/bit ints"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00015}00015 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(long) == 8, \textcolor{stringliteral}{"{}64-\/bit longs"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00016}00016 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00017}00017 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00018}00018 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00019}00019 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00020}00020 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00021}00021 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00022}00022 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00023}00023 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00024}00024 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00025}00025 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00026}00026 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00027}00027 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00028}00028 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00029}00029 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00030}00030 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00031}00031 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00032}00032 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00033}00033 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00034}00034 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00035}00035 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00036}00036 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00037}00037 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00038}00038 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00039}00039 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00040}00040 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00041}00041 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00042}00042 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00043}00043 std::is\_same, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00044}00044 \textcolor{stringliteral}{"{}uint\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00045}00045 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00046}00046 \textcolor{comment}{// print> t\{\};}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00047}00047 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{char}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00048}00048 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00049}00049 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{char}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00050}00050 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00051}00051 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{short}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00052}00052 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00053}00053 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{short}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00054}00054 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00055}00055 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00056}00056 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00057}00057 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00058}00058 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00059}00059 \textcolor{keyword}{static\_assert}(std::is\_same, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{int}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00060}00060 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00061}00061 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00062}00062 std::is\_same<\mbox{\hyperlink{namespacekblib_a54235123af1b79489fb0484fc64318ff}{kblib::int\_smallest\_t}}, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{long}>::value,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00063}00063 \textcolor{stringliteral}{"{}int\_smallest\_t"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00064}00064 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00065}00065 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00066}\mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{00066}} \mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{TEST\_CASE}}(\textcolor{stringliteral}{"{}test\_trie"{}}) \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00067}00067 \mbox{\hyperlink{classkblib_1_1compact__bit__trie}{kblib::compact\_bit\_trie}} \mbox{\hyperlink{main_8cpp_a87feefefd3868afd53b1f40314e0dce0}{test}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00068}00068 REQUIRE(\mbox{\hyperlink{main_8cpp_a87feefefd3868afd53b1f40314e0dce0}{test}}.insert(\{0b1000100010000000, 10\}, 1));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00069}00069 \textcolor{comment}{// has UB, so I hardcoded a test failure as a reminder}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00070}00070 \textcolor{comment}{// std::cout<::value, \textcolor{keywordtype}{int}>::type} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00080}00080 = 0>} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00081}\mbox{\hyperlink{structbuffer_1_1ret__proxy_a8dc4469a7c960d3c3ef91305d8b30028}{00081}} \textcolor{keyword}{operator} T()\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00082}00082 T t;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00083}00083 std::memcpy(\&t, \mbox{\hyperlink{structbuffer_1_1ret__proxy_ab36e9ebc769943385c7f5c8ab5ddf638}{buf}}, \textcolor{keyword}{sizeof}(T));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00084}00084 \textcolor{keywordflow}{return} t;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00085}00085 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00086}00086 \};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00087}\mbox{\hyperlink{structbuffer_aaf27bcfa7a2f145927c6056ab5e400c2}{00087}} std::vector \mbox{\hyperlink{structbuffer_aaf27bcfa7a2f145927c6056ab5e400c2}{buf}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00088}\mbox{\hyperlink{structbuffer_a53374f0f4eb3ee02182c055c1066f0a7}{00088}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{auto} \mbox{\hyperlink{structbuffer_a53374f0f4eb3ee02182c055c1066f0a7}{operator[]}}(std::size\_t p) -\/> \mbox{\hyperlink{structbuffer_1_1ret__proxy}{ret\_proxy}} \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00089}00089 \textcolor{keywordflow}{return} \{\&\mbox{\hyperlink{structbuffer_aaf27bcfa7a2f145927c6056ab5e400c2}{buf}}[p]\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00090}00090 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00091}00091 \};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00092}00092 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00093}00093 \textcolor{keyword}{using }\mbox{\hyperlink{structkblib_1_1bitfield}{kblib::bitfield}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00094}00094 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00095}\mbox{\hyperlink{union_addr1}{00095}} \textcolor{keyword}{union }\mbox{\hyperlink{union_addr1}{Addr1}} \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00096}\mbox{\hyperlink{union_addr1_a398dd464c9b96a17364da2d76cf09cbb}{00096}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<0, 16, uint16\_t>}} \mbox{\hyperlink{union_addr1_a398dd464c9b96a17364da2d76cf09cbb}{raw}}\{\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00097}00097 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00098}\mbox{\hyperlink{union_addr1_a77ee810cb635d83851ff4116ac45758d}{00098}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<0, 5, uint16\_t>}} \mbox{\hyperlink{union_addr1_a77ee810cb635d83851ff4116ac45758d}{cX}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00099}\mbox{\hyperlink{union_addr1_a8d56da01d5b339868cdcfb34abe5c8df}{00099}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<5, 5, uint16\_t>}} \mbox{\hyperlink{union_addr1_a8d56da01d5b339868cdcfb34abe5c8df}{cY}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00100}\mbox{\hyperlink{union_addr1_acb4f84f4b7dd3da329b1f7971dfe55cd}{00100}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<10, 2, uint16\_t>}} \mbox{\hyperlink{union_addr1_acb4f84f4b7dd3da329b1f7971dfe55cd}{nt}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00101}\mbox{\hyperlink{union_addr1_a20ab8a0ce40d18915315dd014fe48f66}{00101}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<12, 3, uint16\_t>}} \mbox{\hyperlink{union_addr1_a20ab8a0ce40d18915315dd014fe48f66}{fY}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00102}00102 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00103}\mbox{\hyperlink{union_addr1_ae83acaf9710b77efddd8e12da2e7a7fb}{00103}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<0, 8, uint16\_t>}} \mbox{\hyperlink{union_addr1_ae83acaf9710b77efddd8e12da2e7a7fb}{l}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00104}\mbox{\hyperlink{union_addr1_ae2871eedbcc9944fcbafa35a73f226a7}{00104}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<8, 7, uint16\_t>}} \mbox{\hyperlink{union_addr1_ae2871eedbcc9944fcbafa35a73f226a7}{h}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00105}00105 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00106}\mbox{\hyperlink{union_addr1_ab882ab71000a51fc244ad86ec881b03f}{00106}} \mbox{\hyperlink{structkblib_1_1bitfield}{bitfield<0, 14, uint16\_t>}} \mbox{\hyperlink{union_addr1_ab882ab71000a51fc244ad86ec881b03f}{addr}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00107}00107 \};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00108}00108 \textcolor{preprocessor}{\#if \_\_cpp\_lib\_is\_pointer\_interconvertible}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00109}00109 \textcolor{keyword}{static\_assert}(std::is\_pointer\_interconvertible\_with\_class(\&\mbox{\hyperlink{union_addr1_a398dd464c9b96a17364da2d76cf09cbb}{Addr1::raw}}));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00110}00110 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00111}00111 std::is\_pointer\_interconvertible\_with\_class(\&\textcolor{keyword}{decltype}(\mbox{\hyperlink{union_addr1_a398dd464c9b96a17364da2d76cf09cbb}{Addr1::raw}})::raw\_));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00112}00112 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00113}00113 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00114}\mbox{\hyperlink{bits_8cpp_a05db7224d3f3eb226cc56286969608f1}{00114}} \mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{TEST\_CASE}}(\textcolor{stringliteral}{"{}bitfields1"{}}) \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00115}00115 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(\mbox{\hyperlink{union_addr1}{Addr1}}) == 2, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00116}00116 \mbox{\hyperlink{union_addr1}{Addr1}} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00117}00117 \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.l = 0b1100'1100;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00118}00118 \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.h(0b001'1001);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00119}00119 REQUIRE(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw == 0b0001'1001'1100'1100);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00120}00120 REQUIRE(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.cX() == 0b0'1100);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00121}00121 REQUIRE(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.cY == 0b0'1110);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00122}00122 REQUIRE(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.nt == 0b10);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00123}00123 REQUIRE(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.fY == 0b001);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00124}00124 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00125}00125 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00126}00126 \textcolor{comment}{// Loopy's VRAM address}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00127}\mbox{\hyperlink{struct_addr}{00127}} \textcolor{keyword}{struct }\mbox{\hyperlink{struct_addr}{Addr}} \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00128}\mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{00128}} std::uint16\_t \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}}\{\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00129}00129 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00130}00130 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(0u, 5u, cX, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00131}00131 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(5u, 5u, cY, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00132}00132 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(10u, 2u, nt, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00133}00133 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(12u, 3u, fY, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00134}00134 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00135}00135 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(0u, 8u, l, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00136}00136 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(8u, 7u, h, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00137}00137 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00138}00138 \mbox{\hyperlink{bits_8h_a15bd8019a95bdacddc1e0c896540fdba}{BITFIELD}}(0u, 14u, addr, \mbox{\hyperlink{struct_addr_a5f7155c9bbbf51ac8180e90c35b1cc6c}{raw}})} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00139}00139 \};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00140}00140 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00141}\mbox{\hyperlink{bits_8cpp_aa71b8d729e21edfe135eebfdb4dbe9ed}{00141}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{bits_8cpp_aa71b8d729e21edfe135eebfdb4dbe9ed}{test\_bitfield}}() -\/> \mbox{\hyperlink{struct_addr}{Addr}} \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00142}00142 \mbox{\hyperlink{struct_addr}{Addr}} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00143}00143 \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.l() = 0b1100'1100;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00144}00144 \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.h(0b001'1001);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00145}00145 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00146}00146 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00147}00147 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00148}\mbox{\hyperlink{bits_8cpp_ae9a4a508d60163ef54b20b17b71db0e2}{00148}} \mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{TEST\_CASE}}(\textcolor{stringliteral}{"{}bitfields"{}}) \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00149}00149 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_addr}{Addr}}) == 2, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00150}00150 \textcolor{keyword}{constexpr} \mbox{\hyperlink{struct_addr}{Addr}} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} = \mbox{\hyperlink{bits_8cpp_aa71b8d729e21edfe135eebfdb4dbe9ed}{test\_bitfield}}();} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00151}00151 \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw == 0b0001'1001'1100'1100, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00152}00152 \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.cX() == 0b0'1100, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00153}00153 \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.cY() == 0b0'1110, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00154}00154 \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.nt() == 0b10, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00155}00155 \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.fY() == 0b001, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00156}00156 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00157}00157 \textcolor{keyword}{static\_assert}(Addr::get\_cX\_v<\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw> == 0b0'1100, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00158}00158 \textcolor{keyword}{static\_assert}(Addr::get\_cY\_v<\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw> == 0b0'1110, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00159}00159 \textcolor{keyword}{static\_assert}(Addr::get\_nt\_v<\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw> == 0b10, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00160}00160 \textcolor{keyword}{static\_assert}(Addr::get\_fY\_v<\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.raw> == 0b001, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00161}00161 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00162}00162 \textcolor{keyword}{constexpr} \mbox{\hyperlink{struct_addr}{Addr}} b = \{Addr::set\_h\_v<0b001'1001, Addr::set\_l\_v<0b1100'1100>>\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00163}00163 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00164}00164 \textcolor{keyword}{static\_assert}(Addr::get\_cX\_v == 0b0'1100, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00165}00165 \textcolor{keyword}{static\_assert}(Addr::get\_cY\_v == 0b0'1110, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00166}00166 \textcolor{keyword}{static\_assert}(Addr::get\_nt\_v == 0b10, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00167}00167 \textcolor{keyword}{static\_assert}(Addr::get\_fY\_v == 0b001, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00168}00168 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00169}00169 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00170}00170 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00171}\mbox{\hyperlink{unionpunner}{00171}} \textcolor{keyword}{union }\mbox{\hyperlink{unionpunner}{punner}} \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00172}\mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{00172}} \textcolor{keywordtype}{char} \mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{storage}}[\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}*)]\{\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00173}\mbox{\hyperlink{unionpunner_af69f01059333f1ce9add0ed59477217c}{00173}} \mbox{\hyperlink{classkblib_1_1union__pun}{kblib::union\_pun}} \mbox{\hyperlink{unionpunner_af69f01059333f1ce9add0ed59477217c}{ptr}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00174}\mbox{\hyperlink{unionpunner_a312555b386cdd5b4004a2ea3632387ee}{00174}} \mbox{\hyperlink{classkblib_1_1union__pun}{kblib::union\_pun}} \mbox{\hyperlink{unionpunner_a312555b386cdd5b4004a2ea3632387ee}{val}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00175}\mbox{\hyperlink{unionpunner_a3ca3d2f715b16baa3c4119fc1ba3cb65}{00175}} \mbox{\hyperlink{classkblib_1_1union__pun}{kblib::union\_pun}}<\textcolor{keywordtype}{char16\_t}[\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}*) / 2], \&\mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{punner::storage}}> \mbox{\hyperlink{unionpunner_a3ca3d2f715b16baa3c4119fc1ba3cb65}{s}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00176}00176 \};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00177}00177 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00178}\mbox{\hyperlink{bits_8cpp_a2c5bb1f5a494be47dfd53a4c13fc1181}{00178}} \mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{TEST\_CASE}}(\textcolor{stringliteral}{"{}union\_punning"{}}) \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00179}00179 \mbox{\hyperlink{unionpunner}{punner}} pun;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00180}00180 std::uintptr\_t ival = 0xABCD;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00181}00181 \mbox{\hyperlink{namespacekblib_ac450342ec31e16201b67e3331a23761d}{kblib::to\_bytes\_le}}(ival, pun.\mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{storage}});} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00182}00182 REQUIRE(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{std::equal}}(std::begin(pun.\mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{storage}}), std::begin(pun.\mbox{\hyperlink{unionpunner_a4fb53ad93577374a4076ba082c54c8f0}{storage}}) + 4,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00183}00183 \textcolor{stringliteral}{"{}\(\backslash\)xCD\(\backslash\)xAB\(\backslash\)0\(\backslash\)0"{}}));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00184}00184 REQUIRE(pun.\mbox{\hyperlink{unionpunner_a312555b386cdd5b4004a2ea3632387ee}{val}} == ival);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00185}00185 std::array ustr\{u\textcolor{stringliteral}{'\(\backslash\)xABCD'}, u\textcolor{charliteral}{'\(\backslash\)0'}\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00186}00186 \textcolor{keyword}{decltype}(ustr) t = pun.\mbox{\hyperlink{unionpunner_a3ca3d2f715b16baa3c4119fc1ba3cb65}{s}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00187}00187 REQUIRE(t == ustr);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00188}00188 REQUIRE(\textcolor{keyword}{decltype}(ustr)(pun.\mbox{\hyperlink{unionpunner_a3ca3d2f715b16baa3c4119fc1ba3cb65}{s}}) == ustr);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00189}00189 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00190}00190 pun.\mbox{\hyperlink{unionpunner_a312555b386cdd5b4004a2ea3632387ee}{val}} = 0;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00191}00191 \textcolor{keyword}{const} \textcolor{keywordtype}{char}* c = \textcolor{stringliteral}{"{}"{}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00192}00192 pun.\mbox{\hyperlink{unionpunner_af69f01059333f1ce9add0ed59477217c}{ptr}} = c;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00193}00193 REQUIRE(pun.\mbox{\hyperlink{unionpunner_a312555b386cdd5b4004a2ea3632387ee}{val}} == kblib::byte\_cast(c));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00194}00194 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00195}00195 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00196}\mbox{\hyperlink{bits_8cpp_a349340569543b95ef42f22f3db20b9b9}{00196}} \mbox{\hyperlink{bits_8cpp_ac5fac09cb98219a12b6983068c144bc0}{TEST\_CASE}}(\textcolor{stringliteral}{"{}punning"{}}) \{} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00197}00197 \mbox{\hyperlink{structkblib_1_1punner}{kblib::punner}}<\textcolor{keywordtype}{char}[], \textcolor{keyword}{const} \textcolor{keywordtype}{char}*, std::uintptr\_t,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00198}00198 \textcolor{keywordtype}{char16\_t}[\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}*) / 2]>} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00199}00199 pun\{\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00200}00200 void(kblib::get<0>(pun));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00201}00201 void(pun.get<1>());} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00202}00202 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00203}00203 std::uintptr\_t ival = 0xABCD;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00204}00204 \mbox{\hyperlink{namespacekblib_ac450342ec31e16201b67e3331a23761d}{kblib::to\_bytes\_le}}(ival, pun.get<0>());} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00205}00205 REQUIRE(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{std::equal}}(std::begin(pun.get<0>()), std::begin(pun.get<0>()) + 4,} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00206}00206 \textcolor{stringliteral}{"{}\(\backslash\)xCD\(\backslash\)xAB\(\backslash\)0\(\backslash\)0"{}}));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00207}00207 REQUIRE(pun.get<2>() == ival);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00208}00208 std::array ustr\{u\textcolor{stringliteral}{'\(\backslash\)xABCD'}, u\textcolor{charliteral}{'\(\backslash\)0'}\};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00209}00209 \textcolor{keyword}{decltype}(ustr) t = pun.get<3>();} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00210}00210 REQUIRE(t == ustr);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00211}00211 REQUIRE(\textcolor{keyword}{decltype}(ustr)(pun.get<3>()) == ustr);} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00212}00212 } \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00213}00213 pun.get<2>() = 0;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00214}00214 \textcolor{keyword}{const} \textcolor{keywordtype}{char}* c = \textcolor{stringliteral}{"{}"{}};} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00215}00215 pun.get<1>() = c;} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00216}00216 REQUIRE(pun.get<2>() == kblib::byte\_cast(c));} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00217}00217 \}} \DoxyCodeLine{\Hypertarget{bits_8cpp_source_l00218}00218 \textcolor{preprocessor}{\#endif}} \end{DoxyCode}