Commit 808c2600 authored by Igor Sugak's avatar Igor Sugak Committed by Facebook GitHub Bot

fix clang-12 -Wdeprecated-copy

Summary:
Starting with C++11, implicit generation of the copy constructor is declared as deprecated.
> § D.2 Implicit declaration of copy functions [depr.impldec]
> The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor (15.4, 15.8). In a future revision of this International Standard, these implicit definitions could become deleted (11.4).

Clang-12 produces diagnostics for these cases, which is turned into errors for folly:
```
folly/test/AtomicHashMapTest.cpp:330:12: error: definition of implicit copy constructor for 'Integer' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  Integer& operator=(const Integer& a) {
           ^
```

Reviewed By: yfeldblum

Differential Revision: D28239770

fbshipit-source-id: a28d19ec774264944b750aa267e93d4fa6d1744e
parent 72bbd4c1
......@@ -27,6 +27,8 @@ struct ExpensiveCopy {
ExpensiveCopy(const ExpensiveCopy&) {
std::this_thread::sleep_for(std::chrono::milliseconds{1});
}
ExpensiveCopy& operator=(const ExpensiveCopy&) = default;
};
#if FOLLY_HAS_COROUTINES
......
......@@ -327,6 +327,8 @@ class Integer {
public:
explicit Integer(KeyT v = 0) : v_(v) {}
Integer(const Integer&) = default;
Integer& operator=(const Integer& a) {
static bool throwException_ = false;
throwException_ = !throwException_;
......
......@@ -71,6 +71,8 @@ struct CountCopyCtor {
++gCount_;
}
CountCopyCtor& operator=(const CountCopyCtor&) = default;
bool operator<(const CountCopyCtor& o) const { return val_ < o.val_; }
int val_;
......
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