11 REQUIRE(dptr ==
nullptr);
15 auto ptr = obj->ref();
20 REQUIRE(obj->data == *ptr);
22 REQUIRE(obj->data == *ptr);
25 REQUIRE(ptr == &obj->data);
32 auto ptr3 = std::move(ptr2);
44 REQUIRE(cptr2 == ptr);
45 auto cptr3 = std::move(cptr2);
63 REQUIRE(dptr ==
nullptr);
67 auto ptr = obj->ref();
72 REQUIRE(obj->data == *ptr);
73 REQUIRE(ptr->length() == 0);
75 REQUIRE(obj->data == *ptr);
76 REQUIRE(ptr->length() == 4);
79 REQUIRE(ptr == &obj->data);
86 auto ptr3 = std::move(ptr2);
98 REQUIRE(cptr2 == ptr);
99 auto cptr3 = std::move(cptr2);
107 REQUIRE(ptr == ptr3);
108 REQUIRE(ptr == dptr);
120 REQUIRE_FALSE(rp.owns());
125 REQUIRE_FALSE(cp.owns());
126 auto up = std::unique_ptr<int>(std::move(rp));
128 up = std::move(op).to_unique();
131 op.reset(up.release(),
true);
135 REQUIRE_FALSE(rp.owns());
142 std::unique_ptr<
int,
decltype(+del)>(
new int{42}, del));
148 REQUIRE_FALSE(rp.owns());
153 REQUIRE_FALSE(cp.owns());
154 auto up = std::unique_ptr<int, decltype(+del)>(std::move(rp));
156 up = std::move(op).to_unique();
159 op.reset(up.release(),
true, up.get_deleter());
163 REQUIRE_FALSE(rp.owns());
170 std::unique_ptr<
int,
decltype(*+del)>(
new int{42}, *del));
176 REQUIRE_FALSE(rp.owns());
181 REQUIRE_FALSE(cp.owns());
182 auto up = std::unique_ptr<int, decltype(*+del)>(std::move(rp));
192 REQUIRE_FALSE(op == rp);
194 REQUIRE_FALSE(rp.owns());
199 REQUIRE_FALSE(cp.owns());
200 auto up = std::unique_ptr<int[]>(std::move(rp));
202 up = std::move(op).to_unique();
205 op.reset(up.release(),
true);
209 REQUIRE_FALSE(rp.owns());
This header provides some features of C++17 <type_traits> and other headers for C++14,...
TEST_CASE("live_ptr<int>")
Provides utilities to enable safe and expressive memory management and low-level memory manipulation.
constexpr auto a(const std::initializer_list< T > &a) -> auto
Index an array literal without naming its type.
auto make_cond_ptr(std::unique_ptr< T, Deleter > &&arg) noexcept -> cond_ptr< T, Deleter >
auto to_unique(owner< T * > p) -> std::unique_ptr< T >