| Index: third_party/WebKit/Source/wtf/Optional.h
|
| diff --git a/third_party/WebKit/Source/wtf/Optional.h b/third_party/WebKit/Source/wtf/Optional.h
|
| index 1c2e422f522d6cb210e65f7ed6f71cf3597c6be4..052250f327ebe199aaf5d49520ce1f8a5f76f3d6 100644
|
| --- a/third_party/WebKit/Source/wtf/Optional.h
|
| +++ b/third_party/WebKit/Source/wtf/Optional.h
|
| @@ -33,39 +33,52 @@ namespace WTF {
|
|
|
| template <typename T>
|
| class Optional final {
|
| - DISALLOW_NEW();
|
| - WTF_MAKE_NONCOPYABLE(Optional);
|
| -public:
|
| - Optional() : m_ptr(nullptr) { }
|
| - ~Optional()
|
| - {
|
| - if (m_ptr)
|
| - m_ptr->~T();
|
| - }
|
| + DISALLOW_NEW();
|
| + WTF_MAKE_NONCOPYABLE(Optional);
|
|
|
| - typedef T* Optional::*UnspecifiedBoolType;
|
| - operator UnspecifiedBoolType() const { return m_ptr ? &Optional::m_ptr : nullptr; }
|
| + public:
|
| + Optional() : m_ptr(nullptr) {}
|
| + ~Optional() {
|
| + if (m_ptr)
|
| + m_ptr->~T();
|
| + }
|
|
|
| - T& operator*() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; }
|
| - const T& operator*() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return *m_ptr; }
|
| - T* operator->() { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return m_ptr; }
|
| - const T* operator->() const { ASSERT_WITH_SECURITY_IMPLICATION(m_ptr); return m_ptr; }
|
| + typedef T* Optional::*UnspecifiedBoolType;
|
| + operator UnspecifiedBoolType() const {
|
| + return m_ptr ? &Optional::m_ptr : nullptr;
|
| + }
|
|
|
| - template <typename... Args>
|
| - void emplace(Args&&... args)
|
| - {
|
| - RELEASE_ASSERT(!m_ptr);
|
| - m_ptr = reinterpret_cast_ptr<T*>(&m_storage.buffer);
|
| - new (m_ptr) T(std::forward<Args>(args)...);
|
| - }
|
| + T& operator*() {
|
| + ASSERT_WITH_SECURITY_IMPLICATION(m_ptr);
|
| + return *m_ptr;
|
| + }
|
| + const T& operator*() const {
|
| + ASSERT_WITH_SECURITY_IMPLICATION(m_ptr);
|
| + return *m_ptr;
|
| + }
|
| + T* operator->() {
|
| + ASSERT_WITH_SECURITY_IMPLICATION(m_ptr);
|
| + return m_ptr;
|
| + }
|
| + const T* operator->() const {
|
| + ASSERT_WITH_SECURITY_IMPLICATION(m_ptr);
|
| + return m_ptr;
|
| + }
|
|
|
| -private:
|
| - T* m_ptr;
|
| - AlignedBuffer<sizeof(T), WTF_ALIGN_OF(T)> m_storage;
|
| + template <typename... Args>
|
| + void emplace(Args&&... args) {
|
| + RELEASE_ASSERT(!m_ptr);
|
| + m_ptr = reinterpret_cast_ptr<T*>(&m_storage.buffer);
|
| + new (m_ptr) T(std::forward<Args>(args)...);
|
| + }
|
| +
|
| + private:
|
| + T* m_ptr;
|
| + AlignedBuffer<sizeof(T), WTF_ALIGN_OF(T)> m_storage;
|
| };
|
|
|
| -} // namespace WTF
|
| +} // namespace WTF
|
|
|
| using WTF::Optional;
|
|
|
| -#endif // Optional_h
|
| +#endif // Optional_h
|
|
|