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

Unified Diff: sky/engine/wtf/OwnPtr.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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/wtf/OwnPtr.h
diff --git a/sky/engine/wtf/OwnPtr.h b/sky/engine/wtf/OwnPtr.h
index 6acbc418a06b1a89530411efeb7765091261d622..a923b152973ddda9597db4594670a1df1ea89619 100644
--- a/sky/engine/wtf/OwnPtr.h
+++ b/sky/engine/wtf/OwnPtr.h
@@ -33,9 +33,11 @@ namespace WTF {
template<typename T> class PassOwnPtr;
template<typename T> class OwnPtr {
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
// If rvalue references are not supported, the copy constructor is
// public so OwnPtr cannot be marked noncopyable. See note below.
WTF_MAKE_NONCOPYABLE(OwnPtr);
+#endif
WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(OwnPtr);
public:
typedef typename RemoveExtent<T>::Type ValueType;
@@ -52,6 +54,14 @@ namespace WTF {
OwnPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
+#if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ // This copy constructor is used implicitly by gcc when it generates
+ // transients for assigning a PassOwnPtr<T> object to a stack-allocated
+ // OwnPtr<T> object. It should never be called explicitly and gcc
+ // should optimize away the constructor when generating code.
+ OwnPtr(const OwnPtr&);
+#endif
+
~OwnPtr()
{
OwnedPtrDeleter<T>::deletePtr(m_ptr);
@@ -79,17 +89,24 @@ namespace WTF {
OwnPtr& operator=(std::nullptr_t) { clear(); return *this; }
template<typename U> OwnPtr& operator=(const PassOwnPtr<U>&);
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
OwnPtr(OwnPtr&&);
template<typename U> OwnPtr(OwnPtr<U>&&);
OwnPtr& operator=(OwnPtr&&);
template<typename U> OwnPtr& operator=(OwnPtr<U>&&);
+#endif
void swap(OwnPtr& o) { std::swap(m_ptr, o.m_ptr); }
static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
private:
+#if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ // If rvalue references are supported, noncopyable takes care of this.
+ OwnPtr& operator=(const OwnPtr&);
+#endif
+
// We should never have two OwnPtrs for the same underlying object (otherwise we'll get
// double-destruction), so these equality operators should never be needed.
template<typename U> bool operator==(const OwnPtr<U>&) const { COMPILE_ASSERT(!sizeof(U*), OwnPtrs_should_never_be_equal); return false; }
@@ -159,6 +176,7 @@ namespace WTF {
return *this;
}
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline OwnPtr<T>::OwnPtr(OwnPtr<T>&& o)
: m_ptr(o.leakPtr())
{
@@ -190,6 +208,7 @@ namespace WTF {
return *this;
}
+#endif
template<typename T> inline void swap(OwnPtr<T>& a, OwnPtr<T>& b)
{

Powered by Google App Engine
This is Rietveld 408576698