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. |