OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // scoped_ptr is just a type alias for std::unique_ptr. Mass conversion coming | 5 // scoped_ptr is just a type alias for std::unique_ptr. Mass conversion coming |
6 // soon (stay tuned for the PSA!), but until then, please continue using | 6 // soon (stay tuned for the PSA!), but until then, please continue using |
7 // scoped_ptr. | 7 // scoped_ptr. |
8 | 8 |
9 #ifndef BASE_MEMORY_SCOPED_PTR_H_ | 9 #ifndef BASE_MEMORY_SCOPED_PTR_H_ |
10 #define BASE_MEMORY_SCOPED_PTR_H_ | 10 #define BASE_MEMORY_SCOPED_PTR_H_ |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 // TODO(dcheng): Temporary, to facilitate transition off scoped_ptr. | |
15 #include "base/memory/ptr_util.h" | |
16 | |
17 template <typename T, typename D = std::default_delete<T>> | 14 template <typename T, typename D = std::default_delete<T>> |
18 using scoped_ptr = std::unique_ptr<T, D>; | 15 using scoped_ptr = std::unique_ptr<T, D>; |
19 | 16 |
| 17 // A function to convert T* into scoped_ptr<T> |
| 18 // Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation |
| 19 // for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) |
| 20 template <typename T> |
| 21 scoped_ptr<T> make_scoped_ptr(T* ptr) { |
| 22 return scoped_ptr<T>(ptr); |
| 23 } |
| 24 |
20 #endif // BASE_MEMORY_SCOPED_PTR_H_ | 25 #endif // BASE_MEMORY_SCOPED_PTR_H_ |
OLD | NEW |