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

Side by Side Diff: sky/engine/wtf/RefPtr.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 26 matching lines...) Expand all
37 WTF_DISALLOW_ZERO_ASSIGNMENT(RefPtr); 37 WTF_DISALLOW_ZERO_ASSIGNMENT(RefPtr);
38 public: 38 public:
39 ALWAYS_INLINE RefPtr() : m_ptr(0) { } 39 ALWAYS_INLINE RefPtr() : m_ptr(0) { }
40 ALWAYS_INLINE RefPtr(std::nullptr_t) : m_ptr(0) { } 40 ALWAYS_INLINE RefPtr(std::nullptr_t) : m_ptr(0) { }
41 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } 41 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); }
42 template<typename U> RefPtr(const RawPtr<U>& ptr, EnsurePtrConvertibleAr gDecl(U, T)) : m_ptr(ptr.get()) { refIfNotNull(m_ptr); } 42 template<typename U> RefPtr(const RawPtr<U>& ptr, EnsurePtrConvertibleAr gDecl(U, T)) : m_ptr(ptr.get()) { refIfNotNull(m_ptr); }
43 ALWAYS_INLINE explicit RefPtr(T& ref) : m_ptr(&ref) { m_ptr->ref(); } 43 ALWAYS_INLINE explicit RefPtr(T& ref) : m_ptr(&ref) { m_ptr->ref(); }
44 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_ ptr); } 44 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_ ptr); }
45 template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgD ecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); } 45 template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgD ecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); }
46 46
47 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
47 RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; } 48 RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; }
48 RefPtr& operator=(RefPtr&&); 49 RefPtr& operator=(RefPtr&&);
50 #endif
49 51
50 // See comments in PassRefPtr.h for an explanation of why this takes a c onst reference. 52 // See comments in PassRefPtr.h for an explanation of why this takes a c onst reference.
51 template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleAr gDecl(U, T)); 53 template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleAr gDecl(U, T));
52 54
53 // Hash table deleted values, which are only constructed and never copie d or destroyed. 55 // Hash table deleted values, which are only constructed and never copie d or destroyed.
54 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { } 56 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
55 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV alue(); } 57 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV alue(); }
56 58
57 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } 59 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); }
58 60
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 derefIfNotNull(ptr); 101 derefIfNotNull(ptr);
100 } 102 }
101 103
102 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr& o) 104 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr& o)
103 { 105 {
104 RefPtr ptr = o; 106 RefPtr ptr = o;
105 swap(ptr); 107 swap(ptr);
106 return *this; 108 return *this;
107 } 109 }
108 110
111 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
109 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o) 112 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o)
110 { 113 {
111 // FIXME: Instead of explicitly casting to RefPtr&& here, we should use std::move, but that requires us to 114 // FIXME: Instead of explicitly casting to RefPtr&& here, we should use std::move, but that requires us to
112 // have a standard library that supports move semantics. 115 // have a standard library that supports move semantics.
113 RefPtr ptr = static_cast<RefPtr&&>(o); 116 RefPtr ptr = static_cast<RefPtr&&>(o);
114 swap(ptr); 117 swap(ptr);
115 return *this; 118 return *this;
116 } 119 }
120 #endif
117 121
118 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera tor=(const RefPtr<U>& o) 122 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera tor=(const RefPtr<U>& o)
119 { 123 {
120 RefPtr ptr = o; 124 RefPtr ptr = o;
121 swap(ptr); 125 swap(ptr);
122 return *this; 126 return *this;
123 } 127 }
124 128
125 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr) 129 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr)
126 { 130 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 private: 215 private:
212 T* m_ptr; 216 T* m_ptr;
213 }; 217 };
214 218
215 } // namespace WTF 219 } // namespace WTF
216 220
217 using WTF::RefPtr; 221 using WTF::RefPtr;
218 using WTF::static_pointer_cast; 222 using WTF::static_pointer_cast;
219 223
220 #endif // WTF_RefPtr_h 224 #endif // WTF_RefPtr_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698