\hypertarget{memory_8cpp_source}{}\doxysection{memory.\+cpp} \label{memory_8cpp_source}\index{tests/memory.cpp@{tests/memory.cpp}} \mbox{\hyperlink{memory_8cpp}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00001}00001 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{memory_8h}{kblib/memory.h}}"{}}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00002}00002 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00003}00003 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00004}00004 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{fakestd_8h}{kblib/fakestd.h}}"{}}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00005}00005 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00006}\mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{00006}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}live\_ptr"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00007}00007 \textcolor{comment}{// default-\/initialized live\_ptrs are null}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00008}00008 \mbox{\hyperlink{classkblib_1_1live__ptr}{kblib::live\_ptr}} dptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00009}00009 REQUIRE(not dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00010}00010 \textcolor{comment}{// can be compared to nullptr}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00011}00011 REQUIRE(dptr == \textcolor{keyword}{nullptr});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00012}00012 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00013}00013 \textcolor{comment}{// obtain a live\_ptr to an object}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00014}00014 \textcolor{keyword}{auto} obj = \mbox{\hyperlink{namespacekblib_af6baba1dcac20a77bc497b45bfe9586c}{kblib::to\_unique}}(\textcolor{keyword}{new} \mbox{\hyperlink{classkblib_1_1live__wrapper}{kblib::live\_wrapper}}\{0\});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00015}00015 \textcolor{keyword}{auto} ptr = obj-\/>ref();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00016}00016 REQUIRE(ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00017}00017 REQUIRE(ptr != dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00018}00018 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00019}00019 \textcolor{comment}{// access through the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00020}00020 REQUIRE(obj-\/>data == *ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00021}00021 ++*ptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00022}00022 REQUIRE(obj-\/>data == *ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00023}00023 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00024}00024 \textcolor{comment}{// can be compared with a raw pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00025}00025 REQUIRE(ptr == \&obj-\/>data);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00026}00026 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00027}00027 \textcolor{comment}{// copy the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00028}00028 \textcolor{keyword}{auto} ptr2 = ptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00029}00029 REQUIRE(ptr == ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00030}00030 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00031}00031 \textcolor{comment}{// move the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00032}00032 \textcolor{keyword}{auto} ptr3 = std::move(ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00033}00033 REQUIRE(ptr3 == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00034}00034 REQUIRE(not ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00035}00035 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00036}00036 \textcolor{comment}{// reassign a pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00037}00037 ptr2 = ptr3;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00038}00038 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00039}00039 \textcolor{comment}{// implicitly add const}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00040}00040 \mbox{\hyperlink{classkblib_1_1live__ptr}{kblib::live\_ptr}} cptr = ptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00041}00041 REQUIRE(cptr == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00042}00042 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00043}00043 \textcolor{keyword}{auto} cptr2 = cptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00044}00044 REQUIRE(cptr2 == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00045}00045 \textcolor{keyword}{auto} cptr3 = std::move(cptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00046}00046 REQUIRE(not cptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00047}00047 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00048}00048 \textcolor{comment}{// destroy the referenced object}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00049}00049 obj.reset();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00050}00050 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00051}00051 \textcolor{comment}{// all pointers to it are now null}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00052}00052 REQUIRE(not ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00053}00053 REQUIRE(ptr == ptr3);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00054}00054 REQUIRE(ptr == dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00055}00055 REQUIRE(not cptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00056}00056 \}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00057}00057 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00058}\mbox{\hyperlink{memory_8cpp_a5732c033c398663b1787a8ff4c0b1a49}{00058}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}live\_ptr"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00059}00059 \textcolor{comment}{// default-\/initialized live\_ptrs are null}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00060}00060 \mbox{\hyperlink{classkblib_1_1live__ptr}{kblib::live\_ptr}} dptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00061}00061 REQUIRE(not dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00062}00062 \textcolor{comment}{// can be compared to nullptr}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00063}00063 REQUIRE(dptr == \textcolor{keyword}{nullptr});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00064}00064 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00065}00065 \textcolor{comment}{// obtain a live\_ptr to an object}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00066}00066 \textcolor{keyword}{auto} obj = \mbox{\hyperlink{namespacekblib_af6baba1dcac20a77bc497b45bfe9586c}{kblib::to\_unique}}(\textcolor{keyword}{new} \mbox{\hyperlink{classkblib_1_1live__wrapper}{kblib::live\_wrapper}}\{\});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00067}00067 \textcolor{keyword}{auto} ptr = obj-\/>ref();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00068}00068 REQUIRE(ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00069}00069 REQUIRE(ptr != dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00070}00070 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00071}00071 \textcolor{comment}{// access through the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00072}00072 REQUIRE(obj-\/>data == *ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00073}00073 REQUIRE(ptr-\/>length() == 0);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00074}00074 *ptr = \textcolor{stringliteral}{"{}test"{}};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00075}00075 REQUIRE(obj-\/>data == *ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00076}00076 REQUIRE(ptr-\/>length() == 4);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00077}00077 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00078}00078 \textcolor{comment}{// can be compared with a raw pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00079}00079 REQUIRE(ptr == \&obj-\/>data);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00080}00080 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00081}00081 \textcolor{comment}{// copy the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00082}00082 \textcolor{keyword}{auto} ptr2 = ptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00083}00083 REQUIRE(ptr == ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00084}00084 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00085}00085 \textcolor{comment}{// move the pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00086}00086 \textcolor{keyword}{auto} ptr3 = std::move(ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00087}00087 REQUIRE(ptr3 == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00088}00088 REQUIRE(not ptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00089}00089 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00090}00090 \textcolor{comment}{// reassign a pointer}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00091}00091 ptr2 = ptr3;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00092}00092 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00093}00093 \textcolor{comment}{// implicitly add const}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00094}00094 \mbox{\hyperlink{classkblib_1_1live__ptr}{kblib::live\_ptr}} cptr = ptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00095}00095 REQUIRE(cptr == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00096}00096 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00097}00097 \textcolor{keyword}{auto} cptr2 = cptr;} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00098}00098 REQUIRE(cptr2 == ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00099}00099 \textcolor{keyword}{auto} cptr3 = std::move(cptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00100}00100 REQUIRE(not cptr2);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00101}00101 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00102}00102 \textcolor{comment}{// destroy the referenced object}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00103}00103 obj.reset();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00104}00104 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00105}00105 \textcolor{comment}{// all pointers to it are now null}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00106}00106 REQUIRE(not ptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00107}00107 REQUIRE(ptr == ptr3);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00108}00108 REQUIRE(ptr == dptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00109}00109 REQUIRE(not cptr);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00110}00110 \}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00111}00111 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00112}\mbox{\hyperlink{memory_8cpp_abe80c0fce44bdad94b612599913d72eb}{00112}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}cond\_ptr"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00113}00113 \textcolor{keywordtype}{int} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}\{42\};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00114}00114 \textcolor{keyword}{auto} op = \mbox{\hyperlink{namespacekblib_af2d860ddf535b7091b11fc07aabe472f}{kblib::make\_cond\_ptr}}(std::make\_unique(42));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00115}00115 \textcolor{keyword}{auto} rp = \mbox{\hyperlink{namespacekblib_af2d860ddf535b7091b11fc07aabe472f}{kblib::make\_cond\_ptr}}(\&\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00116}00116 REQUIRE(op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00117}00117 REQUIRE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00118}00118 REQUIRE(*op == *rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00119}00119 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00120}00120 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00121}00121 \textcolor{keyword}{auto} cp = op.weak();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00122}00122 REQUIRE(cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00123}00123 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00124}00124 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00125}00125 REQUIRE\_FALSE(cp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00126}00126 \textcolor{keyword}{auto} up = std::unique\_ptr(std::move(rp));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00127}00127 REQUIRE\_FALSE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00128}00128 up = std::move(op).to\_unique();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00129}00129 REQUIRE(up == cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00130}00130 REQUIRE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00131}00131 op.reset(up.release(), \textcolor{keyword}{true});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00132}00132 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00133}00133 rp = std::move(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00134}00134 REQUIRE\_FALSE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00135}00135 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00136}00136 \}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00137}00137 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00138}\mbox{\hyperlink{memory_8cpp_aed778fc966b5aea0fdd892e552355101}{00138}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}cond\_ptr fptr"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00139}00139 \textcolor{keyword}{auto} del = [](\mbox{\hyperlink{namespacekblib_a71909c4e14de14b43b7179d2ccb490e8}{kblib::owner}} p) \textcolor{keyword}{noexcept} \{ \textcolor{keyword}{delete} p; \};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00140}00140 \textcolor{keywordtype}{int} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}\{42\};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00141}00141 \textcolor{keyword}{auto} op = \mbox{\hyperlink{classkblib_1_1cond__ptr}{kblib::cond\_ptr}}(} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00142}00142 std::unique\_ptr<\textcolor{keywordtype}{int}, \textcolor{keyword}{decltype}(+del)>(\textcolor{keyword}{new} \textcolor{keywordtype}{int}\{42\}, del));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00143}00143 \textcolor{keyword}{auto} rp = \mbox{\hyperlink{classkblib_1_1cond__ptr}{kblib::cond\_ptr}}(\&\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, del);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00144}00144 REQUIRE(op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00145}00145 REQUIRE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00146}00146 REQUIRE(*op == *rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00147}00147 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00148}00148 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00149}00149 \textcolor{keyword}{auto} cp = op.weak();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00150}00150 REQUIRE(cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00151}00151 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00152}00152 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00153}00153 REQUIRE\_FALSE(cp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00154}00154 \textcolor{keyword}{auto} up = std::unique\_ptr(std::move(rp));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00155}00155 REQUIRE\_FALSE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00156}00156 up = std::move(op).to\_unique();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00157}00157 REQUIRE(up == cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00158}00158 REQUIRE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00159}00159 op.reset(up.release(), \textcolor{keyword}{true}, up.get\_deleter());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00160}00160 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00161}00161 rp = std::move(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00162}00162 REQUIRE\_FALSE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00163}00163 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00164}00164 \}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00165}00165 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00166}\mbox{\hyperlink{memory_8cpp_a2786ed104238755b17fe15f1ca02ed94}{00166}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}cond\_ptr rfptr"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00167}00167 \textcolor{keyword}{auto} del = [](\mbox{\hyperlink{namespacekblib_a71909c4e14de14b43b7179d2ccb490e8}{kblib::owner}} p) \textcolor{keyword}{noexcept} \{ \textcolor{keyword}{delete} p; \};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00168}00168 \textcolor{keywordtype}{int} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}\{42\};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00169}00169 \textcolor{keyword}{auto} op = \mbox{\hyperlink{classkblib_1_1cond__ptr}{kblib::cond\_ptr}}(} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00170}00170 std::unique\_ptr<\textcolor{keywordtype}{int}, \textcolor{keyword}{decltype}(*+del)>(\textcolor{keyword}{new} \textcolor{keywordtype}{int}\{42\}, *del));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00171}00171 \textcolor{keyword}{auto} rp = \mbox{\hyperlink{classkblib_1_1cond__ptr}{kblib::cond\_ptr}}(\&\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, *del);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00172}00172 REQUIRE(op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00173}00173 REQUIRE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00174}00174 REQUIRE(*op == *rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00175}00175 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00176}00176 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00177}00177 \textcolor{keyword}{auto} cp = op.weak();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00178}00178 REQUIRE(cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00179}00179 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00180}00180 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00181}00181 REQUIRE\_FALSE(cp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00182}00182 \textcolor{keyword}{auto} up = std::unique\_ptr(std::move(rp));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00183}00183 REQUIRE\_FALSE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00184}00184 \}} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00185}00185 } \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00186}\mbox{\hyperlink{memory_8cpp_a5ebc636f274e9febbcddd7f0de3a0cd6}{00186}} \mbox{\hyperlink{memory_8cpp_ae7bf02977bc9d087849007a5f5e12454}{TEST\_CASE}}(\textcolor{stringliteral}{"{}cond\_ptr array"{}}) \{} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00187}00187 \textcolor{keywordtype}{int} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}[10]\{42\};} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00188}00188 \textcolor{keyword}{auto} op = \mbox{\hyperlink{namespacekblib_af2d860ddf535b7091b11fc07aabe472f}{kblib::make\_cond\_ptr}}(std::make\_unique<\textcolor{keywordtype}{int}[]>(42));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00189}00189 \textcolor{keyword}{auto} rp = \mbox{\hyperlink{classkblib_1_1cond__ptr}{kblib::cond\_ptr}}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00190}00190 REQUIRE(op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00191}00191 REQUIRE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00192}00192 REQUIRE\_FALSE(op == rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00193}00193 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00194}00194 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00195}00195 \textcolor{keyword}{auto} cp = op.weak();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00196}00196 REQUIRE(cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00197}00197 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00198}00198 REQUIRE(op.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00199}00199 REQUIRE\_FALSE(cp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00200}00200 \textcolor{keyword}{auto} up = std::unique\_ptr(std::move(rp));} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00201}00201 REQUIRE\_FALSE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00202}00202 up = std::move(op).to\_unique();} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00203}00203 REQUIRE(up == cp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00204}00204 REQUIRE(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00205}00205 op.reset(up.release(), \textcolor{keyword}{true});} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00206}00206 REQUIRE(cp == op);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00207}00207 rp = std::move(up);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00208}00208 REQUIRE\_FALSE(rp);} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00209}00209 REQUIRE\_FALSE(rp.owns());} \DoxyCodeLine{\Hypertarget{memory_8cpp_source_l00210}00210 \}} \end{DoxyCode}