From: Yedidya Feldblum Date: Thu, 22 Dec 2016 08:17:20 +0000 (-0800) Subject: Move the guts of try_and_catch into a detail namespace X-Git-Tag: v2017.03.06.00~167 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=c60d131b3e5942b31caa8b4b13c7f9bfa61b986a Move the guts of try_and_catch into a detail namespace Summary: [Folly] Move the guts of `try_and_catch` into a `detail` namespace. Just a bit cleaner this way. Also, now we always slice before returning the derived object, so the derived type never escapes. Reviewed By: luciang Differential Revision: D4361471 fbshipit-source-id: 5c9567d3c5480ee9943a85139b8f27ba3b9da2d6 --- diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index a44d3dd7..c444d1fe 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -395,6 +395,8 @@ fbstring exceptionStr(const exception_wrapper& ew); * }); */ +namespace detail { + template class try_and_catch; @@ -450,5 +452,11 @@ class try_and_catch<> : public exception_wrapper { fn(); } }; +} + +template +exception_wrapper try_and_catch(F&& fn) { + return detail::try_and_catch(std::forward(fn)); +} // detail } // folly