27 :
public arg_type_<decltype(&Fn::operator())> {};
28 template <
class Ret,
class Class,
class Arg>
32 template <
class Ret,
class Class,
class Arg>
36 template <
class Ret,
class Arg>
40 template <
class Ret,
class Arg>
44 template <
class Ret,
class Class>
48 template <
class Ret,
class Class>
61 template <
class Ret,
class...
Args>
71 template <
class Ex,
typename... As>
73 ::new (static_cast<void*>(&
buff_)) Ex(std::forward<As>(as_)...);
78 return *
static_cast<Ex*
>(
static_cast<void*
>(&
buff_));
86 std::exception
const& ex) {
96 "exception_wrapper is untested and possibly broken on your version of " 100 std::exception_ptr
const&
ptr,
103 return reinterpret_cast<std::uintptr_t
>(&e);
118 struct Win32ExceptionPtr {
119 char offset[8 + 4 *
sizeof(
void*)];
120 void* exceptionObject;
124 auto* win32ExceptionPtr =
125 reinterpret_cast<std::shared_ptr<Win32ExceptionPtr>
const*
>(&
ptr)
127 return reinterpret_cast<std::uintptr_t
>(win32ExceptionPtr->exceptionObject);
131 std::exception_ptr
const&,
133 return reinterpret_cast<std::uintptr_t
>(e.typeinfo_) + 1;
136 return 0 == exception_or_type_ % 2;
140 return reinterpret_cast<std::exception
const*
>(exception_or_type_);
143 return reinterpret_cast<std::type_info
const*
>(exception_or_type_ - 1);
158 that->
eptr_.~ExceptionPtr();
163 std::rethrow_exception(that->
eptr_.
ptr_);
167 if (
auto e = get_exception_(that)) {
185 ::new (static_cast<void*>(std::addressof(to->
buff_.
as<Ex>())))
192 ::new (static_cast<void*>(std::addressof(to->
buff_.
as<Ex>())))
221 }
catch (Ex
const& ex) {
232 inline std::exception
const*
253 ::new (static_cast<void*>(std::addressof(to->
sptr_)))
258 that->
sptr_.~SharedPtr();
272 return that->
sptr_.
ptr_->get_exception_();
276 return that->
sptr_.
ptr_->get_exception_ptr_();
279 template <
class Ex,
typename... As>
284 :
eptr_{std::make_exception_ptr(Ex(std::forward<As>(
as)...)),
285 reinterpret_cast<std::uintptr_t
>(std::addressof(
typeid(Ex))) + 1u},
288 template <
class Ex,
typename... As>
293 :
sptr_{std::make_shared<SharedPtr::Impl<Ex>>(std::forward<As>(
as)...)},
296 template <
class Ex,
typename... As>
301 :
buff_{in_place_type<Ex>, std::forward<As>(
as)...},
306 (
vptr_ = that.vptr_)->move_(&that,
this);
321 (
vptr_ = that.vptr_)->move_(&that,
this);
337 std::exception_ptr
ptr,
343 namespace exception_wrapper_detail {
346 assert(
typeid(ex) ==
typeid(
_t<std::decay<Ex>>) ||
347 !
"Dynamic and static exception types don't match. Exception would " 348 "be sliced when storing in exception_wrapper.");
349 return std::forward<Ex>(ex);
382 std::forward<As>(
as)...} {}
395 return !
static_cast<bool>(*this);
413 template <
typename Ex>
420 template <
typename Ex>
422 Ex
const*
object{
nullptr};
427 inline std::exception_ptr
const&
476 std::throw_with_nested(std::forward<Ex>(ex));
480 template <
class CatchFn,
bool IsConst>
485 "Always catch exceptions by reference.");
488 "handle() or with_exception() called on a const exception_wrapper " 489 "and asked to catch a non-const exception. Handler will never fire. " 490 "Catch exception by const reference to fix this.");
494 template <
bool IsConst>
504 return [th = std::forward<ThrowFn>(th), &ca, handled_ = handled_] {
523 return [th = std::forward<ThrowFn>(th), &ca, handled_ = handled_] {
540 template <
bool IsConst>
551 [th = std::forward<ThrowFn>(th), &ca](
auto&& continuation) ->
StdEx* {
552 if (
auto e = const_cast<StdEx*>(th(continuation))) {
568 return [th = std::forward<ThrowFn>(th), &ca](
auto &&) ->
StdEx* {
571 auto continuation = [&ca](
StdEx* e) {
572 return e !=
nullptr ? e : ((void)ca(),
nullptr);
574 if (th(continuation) !=
nullptr) {
584 template <
class This,
class... CatchFns>
590 [&] { this_.throw_exception(); },
597 template <
class This,
class... CatchFns>
604 [&](
auto&& continuation) {
606 const_cast<StdEx*>(this_.vptr_->get_exception_(&this_)));
611 auto continuation = [](StdEx* ex) {
return ex; };
612 if (
nullptr != impl(continuation)) {
613 this_.throw_exception();
617 namespace exception_wrapper_detail {
618 template <
class Ex,
class Fn>
626 template <
class Ex,
class Fn>
636 template <
class Ex,
class This,
class Fn>
643 static_cast<Ex*>(
nullptr),
std::move(fn_));
644 auto&&
all = [&](...) { handled =
false; };
649 template <
class Ex,
class Fn>
651 return with_exception_<Ex>(*
this,
std::move(fn));
653 template <
class Ex,
class Fn>
655 return with_exception_<Ex const>(*
this,
std::move(fn));
658 template <
class... CatchFns>
665 this->
handle_(AllStdEx{}, *
this, fns...);
667 template <
class... CatchFns>
674 this->
handle_(AllStdEx{}, *
this, fns...);
bool has_exception_ptr() const noexcept
folly::fbstring what() const
_t< arg_type_< Fn >> arg_type
static void delete_(exception_wrapper *that)
static exception_wrapper get_exception_ptr_(exception_wrapper const *that)
static bool with_exception_(This &this_, Fn fn_)
FOLLY_PACK_PUSH struct folly::Unaligned< T, typename std::enable_if< std::is_pod< T >::value >::type > FOLLY_PACK_ATTR
void handle(CatchFns...fns)
std::type_info const * as_type_() const
static std::type_info const * type_(exception_wrapper const *)
static std::type_info const & unknown() noexcept
static std::exception const * get_exception_(exception_wrapper const *that)
bool is_compatible_with() const noexcept
std::type_info const *(* type_)(exception_wrapper const *)
#define FOLLY_REQUIRES(...)
constexpr detail::Map< Move > move
Fn catch_(void const *, Fn fn)
static std::exception const * as_exception_or_null_(std::exception const &ex)
std::is_base_of< std::exception, _t< std::decay< Ex >>> IsStdException
exception_wrapper & operator=(exception_wrapper &&that) noexcept
static void move_(exception_wrapper *from, exception_wrapper *to)
static std::type_info const & none() noexcept
exception_wrapper() noexcept
#define FOLLY_REQUIRES_DEF(...)
bool has_exception_() const
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
void throw_() const override
static std::type_info const * type_(exception_wrapper const *that)
requires E e noexcept(noexcept(s.error(std::move(e))))
in_place_tag(&)(in_place_tag) in_place_t
folly::fbstring class_name() const
auto operator()(ThrowFn &&th, CatchFn &ca) const
static exception_wrapper get_exception_ptr_(exception_wrapper const *that)
exception_wrapper_detail::AddConstIf< B, T > AddConstIf
constexpr auto kMicrosoftAbiVer
bool_constant< true > true_type
static void move_(exception_wrapper *from, exception_wrapper *to)
_t< std::conditional< !IsStdException< T >::value, ThrownTag, _t< std::conditional< sizeof(T)<=sizeof(Buffer::Storage)&&alignof(T)<=alignof(Buffer::Storage)&&noexcept(T(std::declval< T && >()))&&noexcept(T(std::declval< T const & >())), InSituTag, OnHeapTag >>>> PlacementOf
static std::type_info const * type_(exception_wrapper const *that)
static void copy_(exception_wrapper const *from, exception_wrapper *to)
std::exception * get_exception() noexcept
static Ret noop_(Args...)
FOLLY_ALWAYS_INLINE void assume_unreachable()
std::exception_ptr const & to_exception_ptr() noexcept
static void onNoExceptionError(char const *name)
std::enable_if< detail::is_chrono_conversion< Tgt, Src >::value, Tgt >::type to(const Src &value)
static std::exception const * get_exception_(exception_wrapper const *that)
static exception_wrapper get_exception_ptr_(exception_wrapper const *that)
void swap(exception_wrapper &that) noexcept
Swaps the value of *this with the value of that
std::shared_ptr< Base > ptr_
Ex && dont_slice(Ex &&ex)
static void throw_(exception_wrapper const *that)
static std::type_info const * uninit_type_(exception_wrapper const *)
static const char *const value
std::exception const * as_exception_() const
static void delete_(exception_wrapper *that)
auto operator()(ThrowFn &&th, CatchFn &ca) const
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::from_fn from
std::type_info const & type() const noexcept
arg_type< _t< std::decay< CatchFn >>> type
catch_fn< Ex, Fn > catch_(Ex *, Fn fn)
static void move_(exception_wrapper *from, exception_wrapper *to)
void throw_exception() const
void(* delete_)(exception_wrapper *)
void(* copy_)(exception_wrapper const *, exception_wrapper *)
static void copy_(exception_wrapper const *from, exception_wrapper *to)
static std::exception const * get_exception_(exception_wrapper const *that)
static std::uintptr_t as_int_(std::exception_ptr const &ptr, std::exception const &e) noexcept
static VTable const uninit_
exception_wrapper get_exception_ptr_() const noexceptoverride
std::is_same< arg_type< _t< std::decay< CatchFn >>>, AnyException > IsCatchAll
static void delete_(exception_wrapper *that)
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto fold(Fn &&, A &&a)
static void handle_(std::false_type, This &this_, CatchFns &...fns)
static void throw_(exception_wrapper const *that)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
exception_wrapper(* get_exception_ptr_)(exception_wrapper const *)
void(* throw_)(exception_wrapper const *)
bool operator!() const noexcept
bool with_exception(Fn fn)
static void throw_(exception_wrapper const *that)
std::exception const *(* get_exception_)(exception_wrapper const *)
void throw_with_nested(Ex &&ex) const
_t< std::conditional< If, const T, T >> AddConstIf
AddConstIf< IsConst, std::exception > StdEx
fbstring demangle(const char *name)
std::exception const * get_exception_() const noexceptoverride
Composed all(Predicate pred=Predicate())
static bool is_const(T &&)
static void copy_(exception_wrapper const *from, exception_wrapper *to)