Commit 1ff074e1 authored by Mikhail Shatalov's avatar Mikhail Shatalov Committed by Facebook GitHub Bot

EventBaseLocal::emplace returns reference to newly created object

Summary: ...to avoid additional `get()` call if we need the emplaced object right after.

Reviewed By: yfeldblum

Differential Revision: D26238594

fbshipit-source-id: a66396173a27ac684b403b3c0c576be50c39dde2
parent f310f66e
......@@ -86,9 +86,11 @@ class EventBaseLocal : public detail::EventBaseLocalBase {
}
template <typename... Args>
void emplace(EventBase& evb, Args&&... args) {
T& emplace(EventBase& evb, Args&&... args) {
auto smartPtr = std::make_shared<T>(std::forward<Args>(args)...);
setVoid(evb, smartPtr);
auto& ref = *smartPtr;
setVoid(evb, std::move(smartPtr));
return ref;
}
template <typename... Args>
......
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