proxygen
folly::exception_wrapper::HandleStdExceptReduce< IsConst > Struct Template Reference

#include <ExceptionWrapper-inl.h>

Public Types

using StdEx = AddConstIf< IsConst, std::exception >
 

Public Member Functions

template<class ThrowFn , class CatchFn , FOLLY_REQUIRES(!IsCatchAll< CatchFn >::value) >
auto operator() (ThrowFn &&th, CatchFn &ca) const
 
template<class ThrowFn , class CatchFn , FOLLY_REQUIRES(IsCatchAll< CatchFn >::value) >
auto operator() (ThrowFn &&th, CatchFn &ca) const
 

Detailed Description

template<bool IsConst>
struct folly::exception_wrapper::HandleStdExceptReduce< IsConst >

Definition at line 541 of file ExceptionWrapper-inl.h.

Member Typedef Documentation

template<bool IsConst>
using folly::exception_wrapper::HandleStdExceptReduce< IsConst >::StdEx = AddConstIf<IsConst, std::exception>

Definition at line 542 of file ExceptionWrapper-inl.h.

Member Function Documentation

template<bool IsConst>
template<class ThrowFn , class CatchFn , FOLLY_REQUIRES(!IsCatchAll< CatchFn >::value) >
auto folly::exception_wrapper::HandleStdExceptReduce< IsConst >::operator() ( ThrowFn &&  th,
CatchFn &  ca 
) const
inline

Definition at line 548 of file ExceptionWrapper-inl.h.

References FOLLY_REQUIRES.

548  {
549  using Ex = _t<ExceptionTypeOf<CatchFn, IsConst>>;
550  return
551  [th = std::forward<ThrowFn>(th), &ca](auto&& continuation) -> StdEx* {
552  if (auto e = const_cast<StdEx*>(th(continuation))) {
553  if (auto e2 = dynamic_cast<_t<std::add_pointer<Ex>>>(e)) {
554  ca(*e2);
555  } else {
556  return e;
557  }
558  }
559  return nullptr;
560  };
561  }
AddConstIf< IsConst, std::exception > StdEx
template<bool IsConst>
template<class ThrowFn , class CatchFn , FOLLY_REQUIRES(IsCatchAll< CatchFn >::value) >
auto folly::exception_wrapper::HandleStdExceptReduce< IsConst >::operator() ( ThrowFn &&  th,
CatchFn &  ca 
) const
inline

Definition at line 567 of file ExceptionWrapper-inl.h.

567  {
568  return [th = std::forward<ThrowFn>(th), &ca](auto &&) -> StdEx* {
569  // The following continuation causes ca() to execute if *this contains
570  // an exception /not/ derived from std::exception.
571  auto continuation = [&ca](StdEx* e) {
572  return e != nullptr ? e : ((void)ca(), nullptr);
573  };
574  if (th(continuation) != nullptr) {
575  ca();
576  }
577  return nullptr;
578  };
579  }
AddConstIf< IsConst, std::exception > StdEx

The documentation for this struct was generated from the following file: