summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2019-11-06 16:44:08 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-11-06 16:44:08 -0800
commit1d73b975fd5a269fc3501b8dfbf37781f0d5d161 (patch)
treef96c9eb74eb74e9aacf65faff9111a293c8d37e6
parent6e622547a597ac442e7d0381a49be00070f7e4cd (diff)
parent2f78d9df0ef144092270c851f07dd0a988b18970 (diff)
downloadnative-1d73b975fd5a269fc3501b8dfbf37781f0d5d161.tar.gz
Merge "libbinder_ndk: ScopedAResource, support move op=" am: 8f0bd5a090
am: 2f78d9df0e Change-Id: I154b230c91021c6a47e6b1446f4ba92f04f7dc2b
-rw-r--r--libs/binder/ndk/include_ndk/android/binder_auto_utils.h11
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.