Commit bf83c8d2 authored by Andrew McFague's avatar Andrew McFague Committed by Facebook GitHub Bot

folly: accept argument to `try_emplace_with` with moveable value

Summary: This allows `try_emplace_with` to receive objects by copy-ellision or specific moves; without it, any attempts to pass an object would result in a copy.

Reviewed By: praihan, luciang

Differential Revision: D26008949

fbshipit-source-id: b43d2dc941c7415e2189668a2b577cc0f1165665
parent 94ddf6ea
...@@ -80,7 +80,7 @@ struct DelayedInit { ...@@ -80,7 +80,7 @@ struct DelayedInit {
* then the provided function is not called. * then the provided function is not called.
*/ */
template <typename Func> template <typename Func>
T& try_emplace_with(Func func) const { T& try_emplace_with(Func&& func) const {
call_once(storage_.init, [&]() mutable { call_once(storage_.init, [&]() mutable {
new (std::addressof(storage_.value)) T(func()); new (std::addressof(storage_.value)) T(func());
}); });
......
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