blob: 56d8da341d2401c93daf92b628d5252e674b75a0 [file] [log] [blame]
zsteinf42cc9d2017-03-27 16:17:19 -07001/*
2 * Copyright 2017 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
Karl Wiberg4c77dcd2018-06-29 14:34:50 +020011// This file contains rtc::MakeUnique and rtc::WrapUnique, which are backwards
12// compatibility aliases for absl::make_unique and absl::WrapUnique,
13// respectively. This file will go away soon; use the Abseil types directly in
14// new code.
zsteinf42cc9d2017-03-27 16:17:19 -070015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#ifndef RTC_BASE_PTR_UTIL_H_
17#define RTC_BASE_PTR_UTIL_H_
zsteinf42cc9d2017-03-27 16:17:19 -070018
Karl Wiberg4c77dcd2018-06-29 14:34:50 +020019#include "absl/memory/memory.h"
zsteinf42cc9d2017-03-27 16:17:19 -070020
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020021namespace rtc {
22
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020023template <typename T, typename... Args>
Karl Wiberg4c77dcd2018-06-29 14:34:50 +020024auto MakeUnique(Args&&... args)
25 -> decltype(absl::make_unique<T, Args...>(std::forward<Args>(args)...)) {
26 return absl::make_unique<T, Args...>(std::forward<Args>(args)...);
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020027}
28
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020029template <typename T>
Karl Wiberg4c77dcd2018-06-29 14:34:50 +020030auto MakeUnique(size_t n) -> decltype(absl::make_unique<T>(n)) {
31 return absl::make_unique<T>(n);
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020032}
33
Karl Wiberg4c77dcd2018-06-29 14:34:50 +020034using absl::WrapUnique;
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020035
36} // namespace rtc
zsteinf42cc9d2017-03-27 16:17:19 -070037
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020038#endif // RTC_BASE_PTR_UTIL_H_