Index: src/interface.cc |
diff --git a/src/interface.cc b/src/interface.cc |
index d325c0e4d845fe0284b340a54768c4bd60f8da42..a45804cf5275eb3674695bd42c73d2c44a20ef7e 100644 |
--- a/src/interface.cc |
+++ b/src/interface.cc |
@@ -14,36 +14,33 @@ namespace internal { |
// --------------------------------------------------------------------------- |
// Initialization. |
-struct Interface::ValueCreate { |
- static void Construct(Interface* ptr) { |
- ::new (ptr) Interface(VALUE + FROZEN); |
- } |
-}; |
- |
- |
-struct Interface::ConstCreate { |
- static void Construct(Interface* ptr) { |
- ::new (ptr) Interface(VALUE + CONST + FROZEN); |
- } |
+struct Interface::Cache { |
+ template<int flags> |
+ struct Create { |
+ static void Construct(Interface* ptr) { ::new (ptr) Interface(flags); } |
+ }; |
+ typedef Create<VALUE + FROZEN> ValueCreate; |
+ typedef Create<VALUE + CONST + FROZEN> ConstCreate; |
+ |
+ static base::LazyInstance<Interface, ValueCreate>::type value_interface; |
+ static base::LazyInstance<Interface, ConstCreate>::type const_interface; |
}; |
-namespace { |
- base::LazyInstance<Interface, Interface::ValueCreate>::type value_interface = |
- LAZY_INSTANCE_INITIALIZER; |
+base::LazyInstance<Interface, Interface::Cache::ValueCreate>::type |
+ Interface::Cache::value_interface = LAZY_INSTANCE_INITIALIZER; |
- base::LazyInstance<Interface, Interface::ConstCreate>::type const_interface = |
- LAZY_INSTANCE_INITIALIZER; |
-} |
+base::LazyInstance<Interface, Interface::Cache::ConstCreate>::type |
+ Interface::Cache::const_interface = LAZY_INSTANCE_INITIALIZER; |
Interface* Interface::NewValue() { |
- return value_interface.Pointer(); // Cached. |
+ return Cache::value_interface.Pointer(); // Cached. |
} |
Interface* Interface::NewConst() { |
- return const_interface.Pointer(); // Cached. |
+ return Cache::const_interface.Pointer(); // Cached. |
} |