You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
694 B
45 lines
694 B
9 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
9 years ago
|
*
|
||
7 years ago
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
9 years ago
|
*/
|
||
|
|
||
|
#include <utility>
|
||
|
|
||
8 years ago
|
namespace move {
|
||
|
|
||
9 years ago
|
struct X {
|
||
|
X() : f(1) {}
|
||
|
X(X&& x) {
|
||
|
f = x.f;
|
||
|
x.f = 0; // assign zero to field of moved_from object
|
||
|
}
|
||
|
int f;
|
||
|
};
|
||
|
|
||
|
int div0_moved_from() {
|
||
|
X x1;
|
||
|
X x2 = std::move(x1);
|
||
|
return 1 / x1.f;
|
||
|
}
|
||
|
|
||
|
int div1_moved_from() {
|
||
|
X x1;
|
||
|
X x2 = std::move(x1);
|
||
|
return 1 / (x1.f + 1);
|
||
|
}
|
||
|
|
||
|
int div1_moved_to() {
|
||
|
X x1;
|
||
|
X x2 = std::move(x1);
|
||
|
return 1 / x2.f;
|
||
|
}
|
||
|
|
||
|
int div0_moved_to() {
|
||
|
X x1;
|
||
|
X x2 = std::move(x1);
|
||
|
return 1 / (x2.f - 1);
|
||
|
}
|
||
7 years ago
|
} // namespace move
|