Commit 22df4521 authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook Github Bot

Returning reference to *this from propagate_const

Summary: As title

Reviewed By: yfeldblum

Differential Revision: D6620395

fbshipit-source-id: 477aae84b2bbde2e79d46ae93c285909b56f575e
parent 5d64a503
......@@ -124,6 +124,7 @@ class propagate_const {
std::is_convertible<OtherPointer&&, Pointer>::value>>>
FOLLY_CPP14_CONSTEXPR propagate_const& operator=(OtherPointer&& other) {
pointer_ = static_cast<OtherPointer&&>(other);
return *this;
}
FOLLY_CPP14_CONSTEXPR void swap(propagate_const& other) noexcept(
......
......@@ -68,6 +68,14 @@ TEST_F(PropagateConstTest, construct_assign) {
EXPECT_FALSE((std::is_assignable<pc<Explicit>, pc<Source>>::value));
}
TEST_F(PropagateConstTest, op_assign_move) {
auto ptr = pc<std::unique_ptr<int>>{std::make_unique<int>(1)};
EXPECT_EQ(*ptr, 1);
ptr = std::make_unique<int>(2);
EXPECT_EQ(*ptr, 2);
}
TEST_F(PropagateConstTest, get) {
int a = 3;
auto pc_a = pc<int*>(&a);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment