X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FExceptionWrapper-inl.h;h=1d74c030d9fbd5e06e98ee4d9b44e956d6731409;hb=HEAD;hp=2845c2e36c8493d63ea05fe1ef11231bcf807448;hpb=e7e6d29a00b685ab673fd76250ca3354088de46b;p=folly.git diff --git a/folly/ExceptionWrapper-inl.h b/folly/ExceptionWrapper-inl.h index 2845c2e3..1d74c030 100644 --- a/folly/ExceptionWrapper-inl.h +++ b/folly/ExceptionWrapper-inl.h @@ -69,9 +69,9 @@ inline std::type_info const* exception_wrapper::uninit_type_( return &typeid(void); } -template -inline exception_wrapper::Buffer::Buffer(in_place_t, Ex&& ex) { - ::new (static_cast(&buff_)) DEx(std::forward(ex)); +template +inline exception_wrapper::Buffer::Buffer(in_place_type_t, As&&... as_) { + ::new (static_cast(&buff_)) Ex(std::forward(as_)...); } template @@ -280,14 +280,30 @@ inline exception_wrapper exception_wrapper::SharedPtr::get_exception_ptr_( return that->sptr_.ptr_->get_exception_ptr_(); } -template -inline exception_wrapper::exception_wrapper(Ex&& ex, OnHeapTag) - : sptr_{std::make_shared>(std::forward(ex))}, +template +inline exception_wrapper::exception_wrapper( + ThrownTag, + in_place_type_t, + As&&... as) + : eptr_{std::make_exception_ptr(Ex(std::forward(as)...)), + reinterpret_cast(std::addressof(typeid(Ex))) + 1u}, + vptr_(&ExceptionPtr::ops_) {} + +template +inline exception_wrapper::exception_wrapper( + OnHeapTag, + in_place_type_t, + As&&... as) + : sptr_{std::make_shared>(std::forward(as)...)}, vptr_(&SharedPtr::ops_) {} -template -inline exception_wrapper::exception_wrapper(Ex&& ex, InSituTag) - : buff_{in_place, std::forward(ex)}, vptr_(&InPlace::ops_) {} +template +inline exception_wrapper::exception_wrapper( + InSituTag, + in_place_type_t, + As&&... as) + : buff_{in_place_type, std::forward(as)...}, + vptr_(&InPlace::ops_) {} inline exception_wrapper::exception_wrapper(exception_wrapper&& that) noexcept : exception_wrapper{} { @@ -334,7 +350,7 @@ Ex&& dont_slice(Ex&& ex) { "be sliced when storing in exception_wrapper."); return std::forward(ex); } -} +} // namespace exception_wrapper_detail template < class Ex, @@ -345,8 +361,9 @@ template < exception_wrapper::IsRegularExceptionType>::value)> inline exception_wrapper::exception_wrapper(Ex&& ex) : exception_wrapper{ - exception_wrapper_detail::dont_slice(std::forward(ex)), - PlacementOf{}} { + PlacementOf{}, + in_place_type, + exception_wrapper_detail::dont_slice(std::forward(ex))} { } template < @@ -356,8 +373,21 @@ template < exception_wrapper::IsRegularExceptionType::value)> inline exception_wrapper::exception_wrapper(in_place_t, Ex&& ex) : exception_wrapper{ - exception_wrapper_detail::dont_slice(std::forward(ex)), - PlacementOf{}} { + PlacementOf{}, + in_place_type, + exception_wrapper_detail::dont_slice(std::forward(ex))} { +} + +template < + class Ex, + typename... As, + FOLLY_REQUIRES_DEF( + exception_wrapper::IsRegularExceptionType::value)> +inline exception_wrapper::exception_wrapper(in_place_type_t, As&&... as) + : exception_wrapper{ + PlacementOf{}, + in_place_type, + std::forward(as)...} { } inline void exception_wrapper::swap(exception_wrapper& that) noexcept { @@ -444,7 +474,7 @@ inline bool exception_wrapper::is_compatible_with() const noexcept { [[noreturn]] inline void exception_wrapper::throw_exception() const { vptr_->throw_(this); - onNoExceptionError(); + onNoExceptionError(__func__); } template @@ -630,7 +660,7 @@ inline void exception_wrapper::handle(CatchFns... fns) { using AllStdEx = exception_wrapper_detail::AllOf...>; if (!*this) { - onNoExceptionError(); + onNoExceptionError(__func__); } this->handle_(AllStdEx{}, *this, fns...); } @@ -639,7 +669,7 @@ inline void exception_wrapper::handle(CatchFns... fns) const { using AllStdEx = exception_wrapper_detail::AllOf...>; if (!*this) { - onNoExceptionError(); + onNoExceptionError(__func__); } this->handle_(AllStdEx{}, *this, fns...); }