From 7ae5a5e444b0589dfaa7b5dee9689e25c6185bfe Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Sun, 21 Aug 2016 10:02:55 -0700 Subject: [PATCH] Get ObserverManager compiling under MSVC Summary: It only needed a minor tweak, but the change still had to be made :( Reviewed By: andriigrynenko Differential Revision: D3745021 fbshipit-source-id: 286c6db706c3571842006537c6b17f506609e51d --- .../experimental/observer/detail/ObserverManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/folly/experimental/observer/detail/ObserverManager.cpp b/folly/experimental/observer/detail/ObserverManager.cpp index 24acabad..e29522ab 100644 --- a/folly/experimental/observer/detail/ObserverManager.cpp +++ b/folly/experimental/observer/detail/ObserverManager.cpp @@ -161,11 +161,16 @@ void ObserverManager::scheduleNext(Core::Ptr core) { struct ObserverManager::Singleton { static folly::Singleton instance; + // MSVC 2015 doesn't let us access ObserverManager's constructor if we + // try to use a lambda to initialize instance, so we have to create + // an actual function instead. + static ObserverManager* createManager() { + return new ObserverManager(); + } }; -folly::Singleton ObserverManager::Singleton::instance([] { - return new ObserverManager(); -}); +folly::Singleton ObserverManager::Singleton::instance( + createManager); std::shared_ptr ObserverManager::getInstance() { return Singleton::instance.try_get(); -- 2.34.1