Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ namespace hpx::serialization {
ptr = helper.t_;
}
}
else
{
ptr.reset();
}
}

template <typename Pointer>
Expand All @@ -431,6 +435,10 @@ namespace hpx::serialization {
{
ptr = detail::pointer_input_dispatcher<Pointer>::type::call(ar);
}
else
{
ptr = Pointer(nullptr);
}
}
} // namespace detail
} // namespace hpx::serialization
32 changes: 32 additions & 0 deletions libs/core/serialization/tests/unit/serialization_smart_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@ void test_unique()
HPX_TEST_EQ(*op2, *ip);
}

void test_shared_null_clears_target()
{
std::shared_ptr<int> const null_ptr;
std::shared_ptr<int> target(new int(4));
{
std::vector<char> buffer;
hpx::serialization::output_archive oarchive(buffer);
oarchive << null_ptr;

hpx::serialization::input_archive iarchive(buffer);
iarchive >> target;
}
HPX_TEST(!target);
}

void test_unique_null_clears_target()
{
std::unique_ptr<int> const null_ptr;
std::unique_ptr<int> target(new int(4));
{
std::vector<char> buffer;
hpx::serialization::output_archive oarchive(buffer);
oarchive << null_ptr;

hpx::serialization::input_archive iarchive(buffer);
iarchive >> target;
}
HPX_TEST(!target);
}

#if defined(HPX_SERIALIZATION_HAVE_BOOST_TYPES)
struct A
{
Expand Down Expand Up @@ -335,6 +365,8 @@ int main()
{
test_shared();
test_unique();
test_shared_null_clears_target();
test_unique_null_clears_target();
test_temporaries<std::shared_ptr<int>>();
test_temporaries<hpx::intrusive_ptr<same_address::counted>>();
#if defined(HPX_SERIALIZATION_HAVE_BOOST_TYPES)
Expand Down
Loading