summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2019-11-07 00:18:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-11-07 00:18:54 +0000
commit8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e (patch)
tree877c252eb7ec42be16c12f9c40ce7c3f6fe621fb
parent19143968d70f10f72327d0eca4152758268dcdad (diff)
parentd329d056a59e9f3452536edd306b9b33f165b074 (diff)
downloadnative-8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e.tar.gz
Merge "libbinder_ndk: ScopedAResource, support move op="
-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.