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

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

Issue 1437943002: Replace WTF::forward with std::forward. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Optional_h 5 #ifndef Optional_h
6 #define Optional_h 6 #define Optional_h
7 7
8 #include "wtf/Alignment.h" 8 #include "wtf/Alignment.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
11 #include "wtf/StdLibExtras.h" 11 #include "wtf/StdLibExtras.h"
12 #include "wtf/Utility.h"
13 12
14 #include <new> 13 #include <new>
14 #include <utility>
15 15
16 namespace WTF { 16 namespace WTF {
17 17
18 // This is a lightweight template similar to std::experimental::optional. 18 // This is a lightweight template similar to std::experimental::optional.
19 // It currently does not support assignment, swapping, comparison, etc. 19 // It currently does not support assignment, swapping, comparison, etc.
20 // 20 //
21 // Use this instead of OwnPtr for cases where you only want to conditionally 21 // Use this instead of OwnPtr for cases where you only want to conditionally
22 // construct a "scope" object. 22 // construct a "scope" object.
23 // 23 //
24 // Example: 24 // Example:
(...skipping 22 matching lines...) Expand all
47 T& operator*() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; } 47 T& operator*() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; }
48 const T& operator*() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; } 48 const T& operator*() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; }
49 T* operator->() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return m_ptr; } 49 T* operator->() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return m_ptr; }
50 const T* operator->() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); retur n m_ptr; } 50 const T* operator->() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); retur n m_ptr; }
51 51
52 template <typename... Args> 52 template <typename... Args>
53 void emplace(Args&&... args) 53 void emplace(Args&&... args)
54 { 54 {
55 RELEASE_ASSERT(!m_ptr); 55 RELEASE_ASSERT(!m_ptr);
56 m_ptr = reinterpret_cast_ptr<T*>(&m_storage.buffer); 56 m_ptr = reinterpret_cast_ptr<T*>(&m_storage.buffer);
57 new (m_ptr) T(forward<Args>(args)...); 57 new (m_ptr) T(std::forward<Args>(args)...);
58 } 58 }
59 59
60 private: 60 private:
61 T* m_ptr; 61 T* m_ptr;
62 AlignedBuffer<sizeof(T), WTF_ALIGN_OF(T)> m_storage; 62 AlignedBuffer<sizeof(T), WTF_ALIGN_OF(T)> m_storage;
63 }; 63 };
64 64
65 } // namespace WTF 65 } // namespace WTF
66 66
67 using WTF::Optional; 67 using WTF::Optional;
68 68
69 #endif // Optional_h 69 #endif // Optional_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.h ('k') | third_party/WebKit/Source/wtf/Utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698