From: James Sedgwick Date: Mon, 17 Nov 2014 23:04:23 +0000 (-0800) Subject: implicit constructor exception_wrapper(std::exception) X-Git-Tag: v0.22.0~171 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a575384b0cf738445a856c5f6fad439224d81c76;p=folly.git implicit constructor exception_wrapper(std::exception) Summary: this should address some of the wordiness issues with exception_wrapper, i.e. always having to use make_exception_wrapper Test Plan: wrote a little test to make sure everything compiles (or doesn't) as expected, not worth committing Reviewed By: davejwatson@fb.com Subscribers: njormrod, folly-diffs@ FB internal diff: D1679460 Signature: t1:1679460:1416265170:5cd72d95dd855cd4e594dbbc49d0c53d012fbc99 --- diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index d14142f0..2fca5c68 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -105,6 +105,14 @@ class exception_wrapper { public: exception_wrapper() : throwfn_(nullptr) { } + // Implicitly construct an exception_wrapper from any std::exception + template ::value>::type> + /* implicit */ exception_wrapper(T&& exn) { + item_ = std::make_shared(std::forward(exn)); + throwfn_ = folly::detail::Thrower::doThrow; + } + void throwException() const { if (throwfn_) { throwfn_(item_.get());