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

Unified Diff: base/lazy_instance.h

Issue 9192024: Add a convenience typedef LazyInstance<T>::Leaky to avoid repeating T. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 11 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 | « base/debug/trace_event.cc ('k') | base/lazy_instance_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/lazy_instance.h
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index ededc73cbbaeba9d426c85e7d85ef4a9be7b0ed6..3d8507845fec921427183197e4d0fb6364948259 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -73,6 +73,11 @@ struct DefaultLazyInstanceTraits {
}
};
+// Use LazyInstance<T>::Leaky for a less-verbose call-site typedef; e.g.:
+// base::LazyInstance<T>::Leaky my_leaky_lazy_instance;
+// instead of:
+// base::LazyInstance<T, LeakyLazyInstanceTraits<T> > my_leaky_lazy_instance;
+// (especially when T is MyLongTypeNameImplClientHolderFactory).
template <typename Type>
struct LeakyLazyInstanceTraits {
static const bool kRegisterOnExit = false;
@@ -117,6 +122,10 @@ class LazyInstance {
// the OnExit member function, where needed.
// ~LazyInstance() {}
+ // Convenience typedef to avoid having to repeat Type for leaky lazy
+ // instances.
+ typedef LazyInstance<Type, LeakyLazyInstanceTraits<Type> > Leaky;
+
Type& Get() {
return *Pointer();
}
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/lazy_instance_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698