2017-03-27 16:17:19 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-06-29 14:34:50 +02:00
|
|
|
// This file contains rtc::MakeUnique and rtc::WrapUnique, which are backwards
|
|
|
|
|
// compatibility aliases for absl::make_unique and absl::WrapUnique,
|
|
|
|
|
// respectively. This file will go away soon; use the Abseil types directly in
|
|
|
|
|
// new code.
|
2017-03-27 16:17:19 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef RTC_BASE_PTR_UTIL_H_
|
|
|
|
|
#define RTC_BASE_PTR_UTIL_H_
|
2017-03-27 16:17:19 -07:00
|
|
|
|
2018-06-29 14:34:50 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2017-03-27 16:17:19 -07:00
|
|
|
|
2017-06-29 07:52:50 +02:00
|
|
|
namespace rtc {
|
|
|
|
|
|
|
|
|
|
template <typename T, typename... Args>
|
2018-06-29 14:34:50 +02:00
|
|
|
auto MakeUnique(Args&&... args)
|
|
|
|
|
-> decltype(absl::make_unique<T, Args...>(std::forward<Args>(args)...)) {
|
|
|
|
|
return absl::make_unique<T, Args...>(std::forward<Args>(args)...);
|
2017-06-29 07:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2018-06-29 14:34:50 +02:00
|
|
|
auto MakeUnique(size_t n) -> decltype(absl::make_unique<T>(n)) {
|
|
|
|
|
return absl::make_unique<T>(n);
|
2017-06-29 07:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-29 14:34:50 +02:00
|
|
|
using absl::WrapUnique;
|
2017-06-29 07:52:50 +02:00
|
|
|
|
|
|
|
|
} // namespace rtc
|
2017-03-27 16:17:19 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // RTC_BASE_PTR_UTIL_H_
|