Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: third_party/WebKit/Source/wtf/PtrUtil.h

Issue 2764833002: Move files in wtf/ to platform/wtf/ (Part 7). (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/PassRefPtr.h ('k') | third_party/WebKit/Source/wtf/RefCounted.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef PtrUtil_h 5 #include "platform/wtf/PtrUtil.h"
6 #define PtrUtil_h
7 6
8 #include "base/memory/ptr_util.h" 7 // The contents of this header was moved to platform/wtf as part of
9 #include "wtf/TypeTraits.h" 8 // WTF migration project. See the following post for details:
10 9 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/tLdAZCTlcAA/bYXVT8gY CAAJ
11 #include <memory>
12
13 namespace WTF {
14
15 template <typename T>
16 std::unique_ptr<T> wrapUnique(T* ptr) {
17 static_assert(
18 !WTF::IsGarbageCollectedType<T>::value,
19 "Garbage collected types should not be stored in std::unique_ptr!");
20 return std::unique_ptr<T>(ptr);
21 }
22
23 template <typename T>
24 std::unique_ptr<T[]> wrapArrayUnique(T* ptr) {
25 static_assert(
26 !WTF::IsGarbageCollectedType<T>::value,
27 "Garbage collected types should not be stored in std::unique_ptr!");
28 return std::unique_ptr<T[]>(ptr);
29 }
30
31 // WTF::makeUnique is base::MakeUnique. See base/ptr_util.h for documentation.
32 template <typename T, typename... Args>
33 auto makeUnique(Args&&... args)
34 -> decltype(base::MakeUnique<T>(std::forward<Args>(args)...)) {
35 static_assert(
36 !WTF::IsGarbageCollectedType<T>::value,
37 "Garbage collected types should not be stored in std::unique_ptr!");
38 return base::MakeUnique<T>(std::forward<Args>(args)...);
39 }
40
41 template <typename T>
42 auto makeUnique(size_t size) -> decltype(base::MakeUnique<T>(size)) {
43 static_assert(
44 !WTF::IsGarbageCollectedType<T>::value,
45 "Garbage collected types should not be stored in std::unique_ptr!");
46 return base::MakeUnique<T>(size);
47 }
48
49 } // namespace WTF
50
51 using WTF::wrapArrayUnique;
52
53 #endif // PtrUtil_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/PassRefPtr.h ('k') | third_party/WebKit/Source/wtf/RefCounted.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698