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

Unified Diff: Source/wtf/OwnPtr.h

Issue 252633005: Enable WTF::HashSet<OwnPtr<> > (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Met comments from Erik Corry Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/HashTraits.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/OwnPtr.h
diff --git a/Source/wtf/OwnPtr.h b/Source/wtf/OwnPtr.h
index e0dde828cec1773f281a3f33752b0897aefeed10..a923b152973ddda9597db4594670a1df1ea89619 100644
--- a/Source/wtf/OwnPtr.h
+++ b/Source/wtf/OwnPtr.h
@@ -22,6 +22,7 @@
#ifndef WTF_OwnPtr_h
#define WTF_OwnPtr_h
+#include "wtf/HashTableDeletedValueType.h"
#include "wtf/Noncopyable.h"
#include "wtf/NullPtr.h"
#include "wtf/OwnPtrCommon.h"
@@ -49,6 +50,10 @@ namespace WTF {
OwnPtr(const PassOwnPtr<T>&);
template<typename U> OwnPtr(const PassOwnPtr<U>&, EnsurePtrConvertibleArgDecl(U, T));
+ // Hash table deleted values, which are only constructed and never copied or destroyed.
+ 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
@@ -94,6 +99,8 @@ namespace WTF {
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.
« no previous file with comments | « Source/wtf/HashTraits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698