\hypertarget{hash_8cpp_source}{}\doxysection{hash.\+cpp} \label{hash_8cpp_source}\index{tests/hash.cpp@{tests/hash.cpp}} \mbox{\hyperlink{hash_8cpp}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00001}00001 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{hash_8h}{kblib/hash.h}}"{}}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00002}00002 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00003}00003 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00004}00004 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00005}00005 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00006}00006 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00007}00007 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00008}00008 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00009}00009 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00010}\mbox{\hyperlink{structhas__padding}{00010}} \textcolor{keyword}{struct }\mbox{\hyperlink{structhas__padding}{has\_padding}} \{} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00011}\mbox{\hyperlink{structhas__padding_a4b9a9e3f17e6afc4cafe182af8dd21e2}{00011}} \textcolor{keywordtype}{char} \mbox{\hyperlink{structhas__padding_a4b9a9e3f17e6afc4cafe182af8dd21e2}{c}};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00012}\mbox{\hyperlink{structhas__padding_aab23df367bdc7d5169a7debfe1d9e1e2}{00012}} \textcolor{keywordtype}{int} \mbox{\hyperlink{structhas__padding_aab23df367bdc7d5169a7debfe1d9e1e2}{i}};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00013}00013 \};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00014}00014 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00015}\mbox{\hyperlink{structno__padding}{00015}} \textcolor{keyword}{struct }\mbox{\hyperlink{structno__padding}{no\_padding}} \{} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00016}\mbox{\hyperlink{structno__padding_a40e9aa9724a2a5f061374dcc17cf0c57}{00016}} \textcolor{keywordtype}{int} \mbox{\hyperlink{structno__padding_a40e9aa9724a2a5f061374dcc17cf0c57}{i}}, \mbox{\hyperlink{structno__padding_afe6182a3e6f10051e21f3a99942e3365}{j}};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00017}00017 \};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00018}00018 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00019}\mbox{\hyperlink{structempty__t}{00019}} \textcolor{keyword}{struct }\mbox{\hyperlink{structempty__t}{empty\_t}} \{\};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00020}00020 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00021}00021 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00022}00022 kblib::is\_linear\_container\_v<} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00023}00023 std::} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00024}00024 string> and kblib::is\_contiguous\_v and kblib::is\_trivially\_hashable\_v and kblib::is\_trivially\_hashable\_v,} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00025}00025 \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00026}00026 \textcolor{keyword}{static\_assert}(kblib::asserts::is\_trivial\_container>, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00027}00027 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00028}00028 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00029}00029 \textcolor{keyword}{static\_assert}(kblib::is\_trivially\_hashable\_v);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00030}00030 \textcolor{keyword}{static\_assert}(std::is\_same\_v<\textcolor{keyword}{decltype}(\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00031}00031 std::declval())),} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00032}00032 std::size\_t>);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00033}00033 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00034}00034 std::is\_default\_constructible\_v<\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}<} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00035}00035 \mbox{\hyperlink{structno__padding}{no\_padding}}>> and std::is\_invocable\_r\_v, \textcolor{keyword}{const} \mbox{\hyperlink{structno__padding}{no\_padding}}\&>);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00036}00036 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00037}00037 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00038}00038 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00039}00039 \textcolor{keyword}{static} \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} is\_disabled\_hash} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00040}00040 = not (std::is\_nothrow\_default\_constructible\_v<\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}<} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00041}00041 T>> and \mbox{\hyperlink{namespacekblib_1_1fakestd_a4e5bf54f9bf20b815a54f4af8ec981e1}{std::is\_invocable\_v}}<\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, \textcolor{keyword}{const} T\&>);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00042}00042 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00043}00043 \textcolor{keyword}{static} \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} is\_enabled\_hash} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00044}00044 = std::is\_nothrow\_default\_constructible\_v>and} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00045}00045 std::is\_invocable\_r\_v, \textcolor{keyword}{const} T\&>;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00046}00046 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00047}\mbox{\hyperlink{hash_8cpp_ab10aed3e6328cbf9116fe3b85d2f7dcf}{00047}} \mbox{\hyperlink{hash_8cpp_ab10aed3e6328cbf9116fe3b85d2f7dcf}{TEST\_CASE}}(\textcolor{stringliteral}{"{}FNV\_hash"{}}) \{} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00048}00048 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00049}00049 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00050}00050 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00051}00051 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00052}00052 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00053}00053 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00054}00054 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00055}00055 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00056}00056 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00057}00057 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00058}00058 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00059}00059 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00060}00060 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00061}00061 std::unordered\_map,} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00062}00062 std::vector>, \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash<>}},} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00063}00063 std::equal\_to<>>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00064}00064 test\_map;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00065}00065 \textcolor{keyword}{using }map\_t = \mbox{\hyperlink{namespacekblib_ae9d0249375b4e261279715b4e50e9bb3}{kblib::hash\_map}},} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00066}00066 std::vector>>;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00067}00067 \textcolor{keyword}{static\_assert}(std::is\_same<\textcolor{keyword}{decltype}(test\_map), map\_t>::value, \textcolor{stringliteral}{"{}"{}});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00068}00068 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}> test\_hash1;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00069}00069 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}> test\_hash1a;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00070}00070 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}> test\_hash1b;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00071}00071 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, \textcolor{keywordtype}{int}>>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00072}00072 test\_hash1c;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00073}00073 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}},} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00074}00074 std::vector>>>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00075}00075 test\_hash2;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00076}00076 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, 4>>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00077}00077 test\_hash3;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00078}00078 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} call = \&\textcolor{keyword}{decltype}(test\_hash1)::operator();} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00079}00079 \textcolor{comment}{// std::hash<}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00080}00080 \textcolor{comment}{// std::unordered\_map>,}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00081}00081 \textcolor{comment}{// std::hash>>}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00082}00082 \textcolor{comment}{// std\_hash;}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00083}00083 \textcolor{keyword}{using namespace }\mbox{\hyperlink{namespacekblib_1_1literals}{kblib::literals}};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00084}00084 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}} h\_i;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00085}00085 \textcolor{keyword}{static\_assert}(3452452\_fnv64 == h\_i(3452452ull),} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00086}00086 \textcolor{stringliteral}{"{}hash literal and FNH\_hash don't agree"{}});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00087}00087 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00088}00088 CHECK(\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(1000) == 0x2fa9eaf82259d71cu);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00089}00089 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00090}00090 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00091}00091 \textcolor{comment}{// fails because of padding:}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00092}00092 \textcolor{keyword}{static\_assert}(is\_disabled\_hash>);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00093}00093 \textcolor{comment}{// fails because of unorderedness:}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00094}00094 \textcolor{keyword}{static\_assert}(is\_disabled\_hash>);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00095}00095 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00096}00096 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}} test\_hash4;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00097}00097 CHECK(test\_hash4(\textcolor{keyword}{nullptr}) != test\_hash4(\&\mbox{\hyperlink{structhas__padding_aab23df367bdc7d5169a7debfe1d9e1e2}{has\_padding::i}}));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00098}00098 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00099}00099 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}> test\_opt\_hash;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00100}00100 (void)test\_opt\_hash(std::nullopt);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00101}00101 (void)test\_opt\_hash(42);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00102}00102 CHECK(test\_opt\_hash(42) == \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(42));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00103}00103 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00104}00104 std::variant var(std::in\_place\_index<1>, 42);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00105}00105 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}<\textcolor{keyword}{decltype}(var)> test\_var\_hash;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00106}00106 CHECK\_FALSE(test\_var\_hash(var) == \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(42));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00107}00107 CHECK\_FALSE(test\_var\_hash(var)} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00108}00108 == test\_var\_hash(\textcolor{keyword}{decltype}(var)\{std::in\_place\_index<0>, 42\}));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00109}00109 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00110}00110 \}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00111}\mbox{\hyperlink{hash_8cpp_a3d96d9e30b93e909773f58bfcc6de172}{00111}} \mbox{\hyperlink{hash_8cpp_ab10aed3e6328cbf9116fe3b85d2f7dcf}{TEST\_CASE}}(\textcolor{stringliteral}{"{}FNV\_hash (32 bit)"{}}) \{} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00112}00112 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00113}00113 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00114}00114 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00115}00115 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00116}00116 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00117}00117 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00118}00118 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00119}00119 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00120}00120 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00121}00121 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00122}00122 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00123}00123 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}::iterator, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00124}00124 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00125}00125 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t> test\_hash1;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00126}00126 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00127}00127 test\_hash1a;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00128}00128 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00129}00129 test\_hash1b;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00130}00130 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, \textcolor{keywordtype}{int}>,} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00131}00131 std::uint32\_t>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00132}00132 test\_hash1c;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00133}00133 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}},} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00134}00134 std::vector>>,} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00135}00135 std::uint32\_t>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00136}00136 test\_hash2;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00137}00137 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00138}00138 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, 4>, std::uint32\_t>} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00139}00139 test\_hash3;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00140}00140 \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} call = \&\textcolor{keyword}{decltype}(test\_hash1)::operator();} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00141}00141 \textcolor{comment}{// std::hash<}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00142}00142 \textcolor{comment}{// std::unordered\_map>,}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00143}00143 \textcolor{comment}{// std::hash>>}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00144}00144 \textcolor{comment}{// std\_hash;}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00145}00145 \textcolor{keyword}{using namespace }\mbox{\hyperlink{namespacekblib_1_1literals}{kblib::literals}};} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00146}00146 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}} h\_i;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00147}00147 \textcolor{keyword}{static\_assert}(3452452\_fnv32 == h\_i(3452452u),} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00148}00148 \textcolor{stringliteral}{"{}hash literal and FNH\_hash don't agree"{}});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00149}00149 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00150}00150 CHECK(\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(1000) == 0xf49c691cu);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00151}00151 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00152}00152 (void)\mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t>\{\}(\{\});} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00153}00153 \textcolor{comment}{// fails because of padding:}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00154}00154 \textcolor{comment}{// kblib::FNV\_hash>\{\}(\{\});}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00155}00155 \textcolor{comment}{// fails because of unorderedness:}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00156}00156 \textcolor{comment}{// kblib::FNV\_hash>\{\}(\{\});}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00157}00157 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00158}00158 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}} test\_hash4;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00159}00159 CHECK(test\_hash4(\textcolor{keyword}{nullptr}) != test\_hash4(\&\mbox{\hyperlink{structhas__padding_aab23df367bdc7d5169a7debfe1d9e1e2}{has\_padding::i}}));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00160}00160 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00161}00161 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}, std::uint32\_t> test\_opt\_hash;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00162}00162 (void)test\_opt\_hash(std::nullopt);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00163}00163 (void)test\_opt\_hash(42);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00164}00164 CHECK(test\_opt\_hash(42) == \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(42));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00165}00165 } \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00166}00166 std::variant var(std::in\_place\_index<1>, 42);} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00167}00167 \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}<\textcolor{keyword}{decltype}(var)> test\_var\_hash;} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00168}00168 CHECK\_FALSE(test\_var\_hash(var) == \mbox{\hyperlink{structkblib_1_1_f_n_v__hash}{kblib::FNV\_hash}}\{\}(42));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00169}00169 CHECK\_FALSE(test\_var\_hash(var)} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00170}00170 == test\_var\_hash(\textcolor{keyword}{decltype}(var)\{std::in\_place\_index<0>, 42\}));} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00171}00171 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{hash_8cpp_source_l00172}00172 \}} \end{DoxyCode}