diff options
author | Steven Moreland <smoreland@google.com> | 2019-11-07 00:18:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-11-07 00:18:54 +0000 |
commit | 8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e (patch) | |
tree | 877c252eb7ec42be16c12f9c40ce7c3f6fe621fb | |
parent | 19143968d70f10f72327d0eca4152758268dcdad (diff) | |
parent | d329d056a59e9f3452536edd306b9b33f165b074 (diff) | |
download | native-8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e.tar.gz |
Merge "libbinder_ndk: ScopedAResource, support move op="
-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. |