| 6 | #define BASE_MEMORY_PTR_UTIL_H_ |
| 7 |
| 8 | #include <memory> |
| 9 | #include <utility> |
| 10 |
| 11 | namespace base { |
| 12 |
| 13 | // Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>. |
| 14 | // Note that std::unique_ptr<T> has very different semantics from |
| 15 | // std::unique_ptr<T[]>: do not use this helper for array allocations. |
| 16 | template <typename T> |
| 17 | std::unique_ptr<T> WrapUnique(T* ptr) { |
| 18 | return std::unique_ptr<T>(ptr); |
| 19 | } |
| 20 |
| 21 | } // namespace base |
| 22 |
| 23 | #endif // BASE_MEMORY_PTR_UTIL_H_ |
| 24 |