summaryrefslogtreecommitdiff
path: root/third_party/base/stl_util.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-19 14:57:42 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-19 14:57:42 -0700
commita752edfd2ddc4913aeffd31b67f6fdb53e4116ae (patch)
treec36366014755593210f8dc806c24774b9066f8c3 /third_party/base/stl_util.h
parentad589d7b83768f3b78ae6b9c90aa418611cc12c2 (diff)
downloadpdfium-a752edfd2ddc4913aeffd31b67f6fdb53e4116ae.tar.xz
Introduce pdfium::FakeUniquePtr for keys to sets of unique ptrs.
Review-Url: https://codereview.chromium.org/2262473002
Diffstat (limited to 'third_party/base/stl_util.h')
-rw-r--r--third_party/base/stl_util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/third_party/base/stl_util.h b/third_party/base/stl_util.h
index 2d1846724c..ccf3c09073 100644
--- a/third_party/base/stl_util.h
+++ b/third_party/base/stl_util.h
@@ -27,6 +27,15 @@ bool ContainsValue(const Collection& collection, const Value& value) {
collection.end();
}
+// Means of generating a key for searching STL collections of std::unique_ptr
+// that avoids the side effect of deleting the pointer.
+template <class T>
+class FakeUniquePtr : public std::unique_ptr<T> {
+ public:
+ using std::unique_ptr<T>::unique_ptr;
+ ~FakeUniquePtr() { std::unique_ptr<T>::release(); }
+};
+
// Convenience routine for "int-fected" code, so that the stl collection
// size_t size() method return values will be checked.
template <typename ResultType, typename Collection>