Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/PtrUtil.h |
| diff --git a/third_party/WebKit/Source/wtf/PtrUtil.h b/third_party/WebKit/Source/wtf/PtrUtil.h |
| index a26aa4cfe2e67008cc175e83c97cbe0fab630051..78d2d2f1e9f36bfdfd784822cc1b009e53420b80 100644 |
| --- a/third_party/WebKit/Source/wtf/PtrUtil.h |
| +++ b/third_party/WebKit/Source/wtf/PtrUtil.h |
| @@ -5,6 +5,7 @@ |
| #ifndef PtrUtil_h |
| #define PtrUtil_h |
| +#include "base/memory/ptr_util.h" |
| #include "wtf/TypeTraits.h" |
| #include <memory> |
| @@ -27,8 +28,27 @@ std::unique_ptr<T[]> wrapArrayUnique(T* ptr) { |
| return std::unique_ptr<T[]>(ptr); |
| } |
| +// WTF::MakeUnique is base::MakeUnique. See base/ptr_util.h for documentation. |
| +template <typename T, typename... Args> |
| +auto MakeUnique(Args&&... args) |
|
Yuta Kitamura
2016/11/04 05:56:23
I want to name it "makeUnique" for now. Having ran
|
| + -> decltype(base::MakeUnique<T>(std::forward<Args>(args)...)) { |
| + static_assert( |
| + !WTF::IsGarbageCollectedType<T>::value, |
| + "Garbage collected types should not be stored in std::unique_ptr!"); |
| + return base::MakeUnique<T>(std::forward<Args>(args)...); |
| +} |
| + |
| +template <typename T> |
| +auto MakeUnique(size_t size) -> decltype(base::MakeUnique<T>(size)) { |
| + static_assert( |
| + !WTF::IsGarbageCollectedType<T>::value, |
| + "Garbage collected types should not be stored in std::unique_ptr!"); |
| + return base::MakeUnique<T>(size); |
| +} |
| + |
| } // namespace WTF |
| +using WTF::MakeUnique; |
| using WTF::wrapUnique; |
| using WTF::wrapArrayUnique; |