Commit a575384b authored by James Sedgwick's avatar James Sedgwick Committed by Dave Watson

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
parent 0a14b4cc
......@@ -105,6 +105,14 @@ class exception_wrapper {
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());
......
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