Move the guts of try_and_catch into a detail namespace
authorYedidya Feldblum <yfeldblum@fb.com>
Thu, 22 Dec 2016 08:17:20 +0000 (00:17 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 22 Dec 2016 08:18:02 +0000 (00:18 -0800)
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

folly/ExceptionWrapper.h

index a44d3dd790206523a10f39a88964294dfcae379d..c444d1fe3015a3290f693936bc6b948bd73fd3e3 100644 (file)
@@ -395,6 +395,8 @@ fbstring exceptionStr(const exception_wrapper& ew);
  * });
  */
 
+namespace detail {
+
 template <typename... Exceptions>
 class try_and_catch;
 
@@ -450,5 +452,11 @@ class try_and_catch<> : public exception_wrapper {
     fn();
   }
 };
+}
+
+template <typename... Exceptions, typename F>
+exception_wrapper try_and_catch(F&& fn) {
+  return detail::try_and_catch<Exceptions...>(std::forward<F>(fn));
+} // detail
 
 } // folly