Commit 9db7434a authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Add Executor::KeepAlive copy-assignment operator

Summary:
[Folly] Add `Executor::KeepAlive` copy-assignment operator. Before this change, the copy-assignment operator is implicitly defined as deleted because it is not explicitly defined and `Executor::KeepAlive` has any of a user-declared move constructor or a user-declared move-assignment operator. This is true even though it has converting assignment operators that look like copy-assignment, because the copy-assignment operator is defined as deleted and it is more specific than the converting assignment operators so it is the best candidate overload at overload resolution time.

See: https://en.cppreference.com/w/cpp/language/copy_assignment.

Reviewed By: andriigrynenko

Differential Revision: D15836577

fbshipit-source-id: 4f0887875db2e0233d48d71f2f05d925300d3dc3
parent 67561821
......@@ -104,6 +104,10 @@ class Executor {
return *this;
}
KeepAlive& operator=(KeepAlive const& other) {
return operator=(folly::copy(other));
}
template <
typename OtherExecutor,
typename = typename std::enable_if<
......
......@@ -148,7 +148,8 @@ TEST(ExecutorTest, KeepAliveCopyAssignment) {
EXPECT_EQ(&exec, ka.get());
EXPECT_EQ(1, exec.refCount);
auto ka2 = ka;
decltype(ka) ka2;
ka2 = ka;
EXPECT_TRUE(ka);
EXPECT_TRUE(ka2);
EXPECT_EQ(&exec, ka2.get());
......
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