28 #include <type_traits> 35 using std::logic_error::logic_error;
54 "Try may not be used with reference types");
80 : contains_(
Contains::VALUE), value_(
v) {}
90 template <
typename...
Args>
93 : contains_(
Contains::VALUE), value_(static_cast<
Args&&>(args)...) {}
96 template <
class T2 = T>
131 template <
typename...
Args>
147 template <
typename...
Args>
178 const T&&
value()
const&&;
183 void throwIfFailed()
const;
243 return contains_ == Contains::VALUE;
257 return hasException() && e_.is_compatible_with<Ex>();
261 if (!hasException()) {
262 throw_exception<TryException>(
"Try does not contain an exception");
268 if (!hasException()) {
269 throw_exception<TryException>(
"Try does not contain an exception");
275 if (!hasException()) {
276 throw_exception<TryException>(
"Try does not contain an exception");
282 if (!hasException()) {
283 throw_exception<TryException>(
"Try does not contain an exception");
293 return hasException() ? e_.get_exception() :
nullptr;
296 return hasException() ? e_.get_exception() :
nullptr;
306 return hasException() ? e_.get_exception<
E>() :
nullptr;
310 return hasException() ? e_.get_exception<
E>() :
nullptr;
320 template <
class Ex,
class F>
322 if (!hasException()) {
325 return e_.with_exception<Ex>(
std::move(func));
327 template <
class Ex,
class F>
329 if (!hasException()) {
332 return e_.with_exception<Ex>(
std::move(func));
345 if (!hasException()) {
348 return e_.with_exception(
std::move(func));
352 if (!hasException()) {
355 return e_.with_exception(
std::move(func));
358 template <
bool isTry,
typename R>
360 return std::forward<R>(*this);
363 template <
bool isTry,
typename R>
365 return std::forward<R>(
value());
412 if (hasException()) {
413 e_.~exception_wrapper();
424 if (hasException()) {
425 e_.~exception_wrapper();
442 template <
typename...
Args>
456 inline void throwIfFailed()
const;
470 return hasException() && e_.is_compatible_with<Ex>();
479 if (!hasException()) {
480 throw_exception<TryException>(
"Try does not contain an exception");
486 if (!hasException()) {
487 throw_exception<TryException>(
"Try does not contain an exception");
493 if (!hasException()) {
494 throw_exception<TryException>(
"Try does not contain an exception");
500 if (!hasException()) {
501 throw_exception<TryException>(
"Try does not contain an exception");
511 return hasException() ? e_.get_exception() :
nullptr;
514 return hasException() ? e_.get_exception() :
nullptr;
524 return hasException() ? e_.get_exception<
E>() :
nullptr;
528 return hasException() ? e_.get_exception<
E>() :
nullptr;
538 template <
class Ex,
class F>
540 if (!hasException()) {
543 return e_.with_exception<Ex>(
std::move(func));
545 template <
class Ex,
class F>
547 if (!hasException()) {
550 return e_.with_exception<Ex>(
std::move(func));
563 if (!hasException()) {
566 return e_.with_exception(
std::move(func));
570 if (!hasException()) {
573 return e_.with_exception(
std::move(func));
576 template <
bool,
typename R>
578 return std::forward<R>(*this);
593 template <
typename F>
594 typename std::enable_if<
595 !std::is_same<invoke_result_t<F>,
void>
::value,
606 template <
typename F>
619 template <
typename T,
typename...
Args>
641 template <typename
T, typename
Func>
655 template <typename
Func>
664 template <typename Tuple>
669 #include <folly/Try-inl.h>
T * tryEmplace(Try< T > &t, Args &&...args) noexcept
bool withException(F func)
bool withException(F func) const
bool hasException() const
const T & operator*() const &
bool withException(F func) const
E const * tryGetExceptionObject() const
exception_wrapper && exception()&&
Try(in_place_t, Args &&...args) noexcept(std::is_nothrow_constructible< T, Args &&... >::value)
bool withException(F func)
std::exception const * tryGetExceptionObject() const
const exception_wrapper & exception() const &
constexpr detail::Map< Move > move
std::exception * tryGetExceptionObject()
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
exception_wrapper & exception()&
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
in_place_tag(&)(in_place_tag) in_place_t
Try(exception_wrapper e) noexcept
bool withException(F func) const
bool withException(F func)
Try(const T &v) noexcept(std::is_nothrow_copy_constructible< T >::value)
T * tryEmplaceWith(Try< T > &t, Func &&func) noexcept
bool hasException() const
bool withException(F func) const
const T && operator*() const &&
bool hasException() const
E * tryGetExceptionObject()
Try(T &&v) noexcept(std::is_nothrow_move_constructible< T >::value)
exception_wrapper & exception()&
std::exception * tryGetExceptionObject()
static const char *const value
Try(const Try< void > &t) noexcept
const exception_wrapper & exception() const &
Try(exception_wrapper e) noexcept
std::enable_if< !std::is_same< invoke_result_t< F >, void >::value, Try< invoke_result_t< F > > >::type makeTryWith(F &&f)
const exception_wrapper && exception() const &&
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
const exception_wrapper && exception() const &&
E * tryGetExceptionObject()
E const * tryGetExceptionObject() const
exception_wrapper && exception()&&
const T * operator->() const
auto unwrapTryTuple(Tuple &&instance)
bool hasException() const
std::exception const * tryGetExceptionObject() const
bool withException(F func)