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

Unified Diff: base/stl_util.h

Issue 10261004: Move both instances of address_of into stl_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to dhallowa review Created 8 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 | « no previous file | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/stl_util.h
diff --git a/base/stl_util.h b/base/stl_util.h
index af77150f6b3a83d6d8081b7182492c0a7c021ac4..6338c7ef7844867e193190e293a61a113e73b6b7 100644
--- a/base/stl_util.h
+++ b/base/stl_util.h
@@ -11,6 +11,19 @@
#include <string>
#include <vector>
+// Return the address of an object as a unary functor.
+// Can be used with std::transform to make a container of pointers from a
+// container of objects.
+// NOTE: Does not work around the possibility that operator & is overloaded.
+template<typename T>
+T* address_of(T& v) {
+ return &v;
+}
+template<typename T>
+const T* const_address_of(const T& v) {
+ return &v;
+}
+
// Clear internal memory of an STL object.
// STL clear()/reserve(0) does not always free internal memory allocated
// This function uses swap/destructor to ensure the internal memory is freed.
« no previous file with comments | « no previous file | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698