Commit 3ce3a0c3 authored by Mainak Mandal's avatar Mainak Mandal Committed by Facebook Github Bot

better error handling for ThreadLocal ctor

Summary: Currently, initializing a `ThreadLocal` with 0 silently passes and then fails at a later stage making it very hard to debug what went wrong

Reviewed By: yfeldblum

Differential Revision: D7326627

fbshipit-source-id: dab62166753168e292f67938c52f82a1b610be2a
parent 13cf726e
......@@ -61,9 +61,11 @@ class ThreadLocal {
return new T();
}) {}
explicit ThreadLocal(std::function<T*()> constructor) :
constructor_(constructor) {
}
template <
typename F,
_t<std::enable_if<is_invocable_r<T*, F>::value, int>> = 0>
explicit ThreadLocal(F&& constructor)
: constructor_(std::forward<F>(constructor)) {}
T* get() const {
T* ptr = tlp_.get();
......
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