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

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: 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
Index: base/stl_util.h
diff --git a/base/stl_util.h b/base/stl_util.h
index af77150f6b3a83d6d8081b7182492c0a7c021ac4..bdc2f14c72ab5ec3226cc8abc0f0459efff692a9 100644
--- a/base/stl_util.h
+++ b/base/stl_util.h
@@ -11,6 +11,19 @@
#include <string>
#include <vector>
+// Find the address of an object as a unary functor.
dhollowa 2012/04/30 16:03:09 s/Find/Return/
gavinp 2012/04/30 16:27:16 Done.
+// 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') | chrome/browser/autofill/personal_data_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698