diff options
author | Steven Moreland <smoreland@google.com> | 2019-11-06 16:38:54 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-11-06 16:38:54 -0800 |
commit | 2f78d9df0ef144092270c851f07dd0a988b18970 (patch) | |
tree | 5dab72fa711863199e955681ccbf9063d7f7f807 | |
parent | 3206a42d841e51b39cc640711a2f3944d75b12f2 (diff) | |
parent | 8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e (diff) | |
download | native-2f78d9df0ef144092270c851f07dd0a988b18970.tar.gz |
Merge "libbinder_ndk: ScopedAResource, support move op="
am: 8f0bd5a090
Change-Id: Ifc08e59f05c3a7b9f7d9621fdcb87a35b85c1d7e
-rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_auto_utils.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h index 8f37c5e3d3..946ccb79a5 100644 --- a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h @@ -159,13 +159,17 @@ class ScopedAResource { */ T* getR() { return &mT; } - // copy-constructing, or move/copy assignment is disallowed + // copy-constructing/assignment is disallowed ScopedAResource(const ScopedAResource&) = delete; ScopedAResource& operator=(const ScopedAResource&) = delete; - ScopedAResource& operator=(ScopedAResource&&) = delete; - // move-constructing is okay + // move-constructing/assignment is okay ScopedAResource(ScopedAResource&& other) : mT(std::move(other.mT)) { other.mT = DEFAULT; } + ScopedAResource& operator=(ScopedAResource&& other) { + set(other.mT); + other.mT = DEFAULT; + return *this; + } private: T mT; @@ -197,6 +201,7 @@ class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delet explicit ScopedAStatus(AStatus* a = nullptr) : ScopedAResource(a) {} ~ScopedAStatus() {} ScopedAStatus(ScopedAStatus&&) = default; + ScopedAStatus& operator=(ScopedAStatus&&) = default; /** * See AStatus_isOk. |