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
public:
exception_wrapper() : throwfn_(nullptr) { }
+ // Implicitly construct an exception_wrapper from any std::exception
+ template <typename T, typename =
+ typename std::enable_if<std::is_base_of<std::exception, T>::value>::type>
+ /* implicit */ exception_wrapper(T&& exn) {
+ item_ = std::make_shared<T>(std::forward<T>(exn));
+ throwfn_ = folly::detail::Thrower<T>::doThrow;
+ }
+
void throwException() const {
if (throwfn_) {
throwfn_(item_.get());