henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 11 | // This entire file is deprecated, and will be removed in XXXX 2016. Use |
| 12 | // std::unique_ptr instead! |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef WEBRTC_BASE_SCOPED_PTR_H__ |
| 15 | #define WEBRTC_BASE_SCOPED_PTR_H__ |
| 16 | |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 17 | // All these #includes are left to maximize backwards compatibility. |
kwiberg@webrtc.org | 73ca194 | 2015-01-29 09:12:47 +0000 | [diff] [blame] | 18 | |
| 19 | #include <assert.h> |
| 20 | #include <stddef.h> |
| 21 | #include <stdlib.h> |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 22 | |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 23 | #include <algorithm> |
kwiberg | 9390f84 | 2015-12-17 06:20:27 -0800 | [diff] [blame] | 24 | #include <cstddef> |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 25 | #include <memory> |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 26 | |
kwiberg@webrtc.org | 73ca194 | 2015-01-29 09:12:47 +0000 | [diff] [blame] | 27 | #include "webrtc/base/constructormagic.h" |
kwiberg@webrtc.org | 73ca194 | 2015-01-29 09:12:47 +0000 | [diff] [blame] | 28 | #include "webrtc/base/template_util.h" |
| 29 | #include "webrtc/typedefs.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 30 | |
| 31 | namespace rtc { |
| 32 | |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 33 | template <typename T, typename Deleter = std::default_delete<T>> |
| 34 | using scoped_ptr = std::unique_ptr<T, Deleter>; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 35 | |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 36 | // These used to convert between rtc::scoped_ptr and std::unique_ptr. Now they |
| 37 | // are no-ops. |
kwiberg@webrtc.org | 73ca194 | 2015-01-29 09:12:47 +0000 | [diff] [blame] | 38 | template <typename T> |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 39 | std::unique_ptr<T> ScopedToUnique(std::unique_ptr<T> up) { |
| 40 | return up; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 41 | } |
| 42 | template <typename T> |
kwiberg | ba5ea44 | 2016-04-25 18:08:40 -0700 | [diff] [blame] | 43 | std::unique_ptr<T> UniqueToScoped(std::unique_ptr<T> up) { |
| 44 | return up; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Karl Wiberg | 9478437 | 2015-04-20 14:03:07 +0200 | [diff] [blame] | 47 | } // namespace rtc |
| 48 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 49 | #endif // #ifndef WEBRTC_BASE_SCOPED_PTR_H__ |