Add swap operation to UniquePtr.

Enables swapping without mPtr ever becoming null. Required by
https://googleplex-android-review.googlesource.com/#/c/250540/

(cherry picked from commit be7922da0cf9b759f01f09b5f259e083f8d1f0b8)

Change-Id: I06ec54e174d251cd2938efba8e628d0eaf6ebcc5
diff --git a/include/nativehelper/UniquePtr.h b/include/nativehelper/UniquePtr.h
index 31db377..e27e941 100644
--- a/include/nativehelper/UniquePtr.h
+++ b/include/nativehelper/UniquePtr.h
@@ -17,6 +17,7 @@
 #ifndef UNIQUE_PTR_H_included
 #define UNIQUE_PTR_H_included
 
+#include <algorithm> // For std::swap
 #include <cstdlib> // For NULL.
 
 // Default deleter for pointer types.
@@ -80,6 +81,11 @@
         }
     }
 
+    // Swap with another unique pointer.
+    void swap(UniquePtr<T>& other) {
+      std::swap(mPtr, other.mPtr);
+    }
+
 private:
     // The raw pointer.
     T* mPtr;