Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: base/memory/ptr_util.h

Issue 1513423002: Add WrapUnique helper to wrap a raw pointer in a std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and add comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/memory/BUILD.gn ('k') | base/memory/ptr_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_MEMORY_PTR_UTIL_H_
6 #define BASE_MEMORY_PTR_UTIL_H_
7
8 #include <memory>
9
10 namespace base {
11
12 // Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
13 // Note that std::unique_ptr<T> has very different semantics from
14 // std::unique_ptr<T[]>: do not use this helper for array allocations.
15 template <typename T>
16 std::unique_ptr<T> WrapUnique(T* ptr) {
17 return std::unique_ptr<T>(ptr);
18 }
19
20 } // namespace base
21
22 #endif // BASE_MEMORY_PTR_UTIL_H_
OLDNEW
« no previous file with comments | « base/memory/BUILD.gn ('k') | base/memory/ptr_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698