28 #include <type_traits> 42 #pragma GCC diagnostic push 43 #pragma GCC diagnostic ignored "-Wpragmas" 44 #pragma GCC diagnostic ignored "-Wpotentially-evaluated-expression" 50 #define FOLLY_EXCEPTION_WRAPPER_H_INCLUDED 54 #define FOLLY_REQUIRES_DEF(...) \ 55 _t<std::enable_if<static_cast<bool>(__VA_ARGS__), long>> 57 #define FOLLY_REQUIRES(...) FOLLY_REQUIRES_DEF(__VA_ARGS__) = __LINE__ 59 namespace exception_wrapper_detail {
61 template <
template <
class>
class T,
class... As>
64 template <
bool If,
class T>
67 template <
class Fn,
class A>
69 return static_cast<A&&
>(
a);
72 template <
class Fn,
class A,
class B,
class... Bs>
74 fold(Fn&& fn, A&&
a, B&&
b, Bs&&... bs) {
80 static_cast<Fn&&>(fn),
81 static_cast<Fn&&>(fn)(static_cast<A&&>(
a), static_cast<B&&>(
b)),
82 static_cast<Bs&&>(bs)...);
199 [[noreturn]]
static void onNoExceptionError(
char const*
name);
201 template <
class Ret,
class...
Args>
202 static Ret noop_(
Args...);
210 template <
bool B,
class T>
212 template <
class CatchFn>
229 template <
class Ex,
typename... As>
253 static std::exception
const* as_exception_or_null_(std::exception
const& ex);
254 static std::exception
const* as_exception_or_null_(AnyException);
260 1 <
alignof(std::exception) && 1 <
alignof(std::type_info),
261 "Surprise! std::exception and std::type_info don't have alignment " 262 "greater than one. as_int_ below will not work!");
264 static std::uintptr_t as_int_(
265 std::exception_ptr
const&
ptr,
267 static std::uintptr_t as_int_(
268 std::exception_ptr
const&
ptr,
270 bool has_exception_()
const;
271 std::exception
const* as_exception_()
const;
272 std::type_info
const* as_type_()
const;
293 static constexpr
VTable const ops_{copy_,
306 explicit Base(std::type_info
const&
info) : info_(&info) {}
308 virtual void throw_()
const = 0;
309 virtual std::exception
const* get_exception_()
const noexcept = 0;
318 template <
typename... As>
320 :
Base{
typeid(Ex)}, ex_(std::forward<As>(
as)...) {}
321 [[noreturn]]
void throw_()
const override;
323 std::exception
const* get_exception_()
const noexcept override;
345 template <
class Ex,
typename... As>
348 template <
class Ex,
typename... As>
351 template <
class Ex,
typename... As>
357 std::is_copy_constructible<T>,
358 Negation<std::is_base_of<exception_wrapper, T>>,
359 Negation<std::is_abstract<T>>> {};
361 template <
class CatchFn,
bool IsConst = false>
364 template <
bool IsConst>
367 template <
bool IsConst>
370 template <
class This,
class... CatchFns>
373 template <
class This,
class... CatchFns>
374 static void handle_(
std::true_type, This& this_, CatchFns&... fns);
376 template <
class Ex,
class This,
class Fn>
377 static bool with_exception_(This& this_, Fn fn_);
380 static exception_wrapper from_exception_ptr(
381 std::exception_ptr
const& eptr)
noexcept;
390 exception_wrapper(exception_wrapper&& that)
noexcept;
395 exception_wrapper(exception_wrapper
const& that)
noexcept;
401 exception_wrapper& operator=(exception_wrapper&& that)
noexcept;
406 exception_wrapper& operator=(exception_wrapper
const& that)
noexcept;
408 ~exception_wrapper();
415 explicit exception_wrapper(std::exception_ptr
ptr)
noexcept;
422 exception_wrapper(std::exception_ptr ptr, Ex& ex)
noexcept;
435 exception_wrapper(Ex&& ex);
460 explicit operator bool()
const noexcept;
473 bool has_exception_ptr()
const noexcept;
489 template <
typename Ex>
492 template <
typename Ex>
501 std::exception_ptr
const& to_exception_ptr()
noexcept;
503 std::exception_ptr to_exception_ptr()
const noexcept;
511 static std::type_info
const& unknown()
noexcept;
533 bool is_compatible_with()
const noexcept;
544 [[noreturn]]
void throw_with_nested(Ex&& ex)
const;
572 template <
class Ex =
void const,
class Fn>
573 bool with_exception(Fn fn);
575 template <
class Ex =
void const,
class Fn>
576 bool with_exception(Fn fn)
const;
611 template <
class... CatchFns>
612 void handle(CatchFns... fns);
614 template <
class... CatchFns>
615 void handle(CatchFns... fns)
const;
625 template <
class Ex,
typename... As>
636 std::basic_ostream<Ch>& sout,
638 return sout << ew.
what();
652 template <
typename F>
657 template <
typename F,
typename Ex,
typename... Exs>
702 template <
typename... Exceptions,
typename F>
710 #undef FOLLY_REQUIRES 711 #undef FOLLY_REQUIRES_DEF 713 #pragma GCC diagnostic pop
TransportDirection operator!(TransportDirection dir)
folly::fbstring what() const
Base(std::type_info const &info)
_t< arg_type_< Fn >> arg_type
#define FOLLY_ALWAYS_INLINE
_t< std::aligned_storage< 2 *sizeof(void *), alignof(std::exception)>> Storage
#define FOLLY_REQUIRES(...)
fbstring exceptionStr(const std::exception &e)
std::is_base_of< std::exception, _t< std::decay< Ex >>> IsStdException
exception_wrapper() noexcept
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
in_place_tag(&)(in_place_tag) in_place_t
exception_wrapper_detail::AddConstIf< B, T > AddConstIf
bool_constant< true > true_type
_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
exception_wrapper try_and_catch_(F &&f)
std::enable_if< detail::is_chrono_conversion< Tgt, Src >::value, Tgt >::type to(const Src &value)
std::shared_ptr< Base > ptr_
AtomicCounter< T, DeterministicAtomic > Base
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::from_fn from
exception_wrapper try_and_catch(F &&fn)
exception_wrapper make_exception_wrapper(As &&...as)
std::type_info const * info_
#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
static VTable const uninit_
std::is_same< arg_type< _t< std::decay< CatchFn >>>, AnyException > IsCatchAll
exception_wrapper try_and_catch_(F &&f)
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto fold(Fn &&, A &&a)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
std::uintptr_t exception_or_type_
#define FOLLY_ATTR_VISIBILITY_HIDDEN
_t< std::conditional< If, const T, T >> AddConstIf
std::type_info const * typeinfo_
AnyException(T &&t) noexcept
static E * get_exception(std::exception_ptr eptr)
FOLLY_NOINLINE FOLLY_COLD void throw_exception(Ex &&ex)
std::ostream & operator<<(std::ostream &out, dynamic const &d)