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;
typedef ValueType* PtrType;
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);
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; }
return *this;
}
-#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline OwnPtr<T>::OwnPtr(OwnPtr<T>&& o)
: m_ptr(o.leakPtr())
{
return *this;
}
-#endif
template<typename T> inline void swap(OwnPtr<T>& a, OwnPtr<T>& b)
{