Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d73b975 authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "libbinder_ndk: ScopedAResource, support move op=" am: 8f0bd5a0

am: 2f78d9df

Change-Id: I154b230c91021c6a47e6b1446f4ba92f04f7dc2b
parents 6e622547 2f78d9df
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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.