Commit 62887e3e authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

fix SingletonThreadLocal::try_get

Summary: Fixes an improper cast. `SingletonThreadLocal` allows a factory which returns any type, as long as that type can be reference-cast to the target type. So the new code must do a reference-cast.

Reviewed By: amlannayak

Differential Revision: D31022770

fbshipit-source-id: 0fce6008fc3e21b6082ec7dcf3c3f9019b541ae9
parent e698dfa1
......@@ -158,7 +158,7 @@ class SingletonThreadLocal {
static T* try_get() {
auto* wrapper = getWrapperTL().getIfExist();
return wrapper ? &wrapper->object : nullptr;
return wrapper ? &static_cast<T&>(*wrapper) : nullptr;
}
class Accessor {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment