proxygen
folly::Try< void > Class Template Reference

#include <Try.h>

Public Types

typedef void element_type
 

Public Member Functions

 Try () noexcept
 
 Try (exception_wrapper e) noexcept
 
Tryoperator= (const Try< void > &t) noexcept
 
 Try (const Try< void > &t) noexcept
 
 ~Try ()
 
void emplace () noexcept
 
template<typename... Args>
exception_wrapperemplaceException (Args &&...args) noexcept(std::is_nothrow_constructible< exception_wrapper, Args &&... >::value)
 
void value () const
 
void operator* () const
 
void throwIfFailed () const
 
bool hasValue () const
 
bool hasException () const
 
template<class Ex >
bool hasException () const
 
exception_wrapperexception ()&
 
exception_wrapper && exception ()&&
 
const exception_wrapperexception () const &
 
const exception_wrapper && exception () const &&
 
std::exception * tryGetExceptionObject ()
 
std::exception const * tryGetExceptionObject () const
 
template<class E >
EtryGetExceptionObject ()
 
template<class E >
E const * tryGetExceptionObject () const
 
template<class Ex , class F >
bool withException (F func)
 
template<class Ex , class F >
bool withException (F func) const
 
template<class F >
bool withException (F func)
 
template<class F >
bool withException (F func) const
 
template<bool , typename R >
get ()
 

Private Attributes

bool hasValue_
 
union folly::Try< void >:: { ... }  
 

Detailed Description

template<>
class folly::Try< void >

Definition at line 383 of file Try.h.

Member Typedef Documentation

typedef void folly::Try< void >::element_type

Definition at line 388 of file Try.h.

Constructor & Destructor Documentation

folly::Try< void >::Try ( )
inlinenoexcept

Definition at line 391 of file Try.h.

391 : hasValue_(true) {}
bool hasValue_
Definition: Try.h:582
folly::Try< void >::Try ( exception_wrapper  e)
inlineexplicitnoexcept

Definition at line 398 of file Try.h.

References folly::pushmi::__adl::noexcept().

399  : hasValue_(false), e_(std::move(e)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool hasValue_
Definition: Try.h:582
exception_wrapper e_
Definition: Try.h:584
folly::Try< void >::Try ( const Try< void > &  t)
inlinenoexcept

Definition at line 405 of file Try.h.

References e_, and hasException().

405  : hasValue_(t.hasValue_) {
406  if (t.hasException()) {
407  new (&e_) exception_wrapper(t.e_);
408  }
409  }
bool hasValue_
Definition: Try.h:582
exception_wrapper e_
Definition: Try.h:584
folly::Try< void >::~Try ( )
inline

Definition at line 411 of file Try.h.

411  {
412  if (hasException()) {
414  }
415  }
bool hasException() const
Definition: Try.h:463
exception_wrapper e_
Definition: Try.h:584

Member Function Documentation

void folly::Try< void >::emplace ( )
inlinenoexcept

Definition at line 423 of file Try.h.

References testing::Args(), folly::pushmi::__adl::noexcept(), and value.

Referenced by TEST(), and folly::tryEmplaceWith().

423  {
424  if (hasException()) {
426  hasValue_ = true;
427  }
428  }
bool hasException() const
Definition: Try.h:463
bool hasValue_
Definition: Try.h:582
exception_wrapper e_
Definition: Try.h:584
template<typename... Args>
exception_wrapper & folly::Try< void >::emplaceException ( Args &&...  args)
noexcept

Definition at line 203 of file Try-inl.h.

References folly::Try< T >::e_, folly::Try< T >::hasException(), and folly::exception_wrapper::~exception_wrapper().

Referenced by TEST(), and folly::tryEmplaceWith().

204  {
205  if (hasException()) {
207  }
208  new (&e_) exception_wrapper(static_cast<Args&&>(args)...);
209  hasValue_ = false;
210  return e_;
211 }
bool hasException() const
Definition: Try.h:463
bool hasValue_
Definition: Try.h:582
exception_wrapper e_
Definition: Try.h:584
exception_wrapper& folly::Try< void >::exception ( )
inline

Definition at line 478 of file Try.h.

478  {
479  if (!hasException()) {
480  throw_exception<TryException>("Try does not contain an exception");
481  }
482  return e_;
483  }
bool hasException() const
Definition: Try.h:463
exception_wrapper e_
Definition: Try.h:584
exception_wrapper&& folly::Try< void >::exception ( )
inline

Definition at line 485 of file Try.h.

References folly::gen::move.

485  {
486  if (!hasException()) {
487  throw_exception<TryException>("Try does not contain an exception");
488  }
489  return std::move(e_);
490  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584
const exception_wrapper& folly::Try< void >::exception ( ) const
inline

Definition at line 492 of file Try.h.

492  {
493  if (!hasException()) {
494  throw_exception<TryException>("Try does not contain an exception");
495  }
496  return e_;
497  }
bool hasException() const
Definition: Try.h:463
exception_wrapper e_
Definition: Try.h:584
const exception_wrapper&& folly::Try< void >::exception ( ) const
inline

Definition at line 499 of file Try.h.

References folly::gen::move.

499  {
500  if (!hasException()) {
501  throw_exception<TryException>("Try does not contain an exception");
502  }
503  return std::move(e_);
504  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584
template<bool , typename R >
R folly::Try< void >::get ( )
inline

Definition at line 577 of file Try.h.

577  {
578  return std::forward<R>(*this);
579  }
bool folly::Try< void >::hasException ( ) const
inline

Definition at line 463 of file Try.h.

Referenced by TEST(), and Try().

463  {
464  return !hasValue_;
465  }
bool hasValue_
Definition: Try.h:582
template<class Ex >
bool folly::Try< void >::hasException ( ) const
inline

Definition at line 469 of file Try.h.

469  {
470  return hasException() && e_.is_compatible_with<Ex>();
471  }
bool hasException() const
Definition: Try.h:463
bool is_compatible_with() const noexcept
exception_wrapper e_
Definition: Try.h:584
bool folly::Try< void >::hasValue ( ) const
inline

Definition at line 459 of file Try.h.

Referenced by TEST().

459  {
460  return hasValue_;
461  }
bool hasValue_
Definition: Try.h:582
void folly::Try< void >::operator* ( ) const
inline

Definition at line 451 of file Try.h.

References folly::value().

451  {
452  return value();
453  }
void value() const
Definition: Try.h:447
Try< void > & folly::Try< void >::operator= ( const Try< void > &  t)
inlinenoexcept

Definition at line 185 of file Try-inl.h.

References testing::Args(), folly::pushmi::detail::t, and folly::exception_wrapper::~exception_wrapper().

185  {
186  if (t.hasException()) {
187  if (hasException()) {
188  e_ = t.e_;
189  } else {
190  new (&e_) exception_wrapper(t.e_);
191  hasValue_ = false;
192  }
193  } else {
194  if (hasException()) {
196  hasValue_ = true;
197  }
198  }
199  return *this;
200 }
bool hasException() const
Definition: Try.h:463
bool hasValue_
Definition: Try.h:582
exception_wrapper e_
Definition: Try.h:584
void folly::Try< void >::throwIfFailed ( ) const
inline

Definition at line 213 of file Try-inl.h.

References folly::Try< T >::e_, folly::Try< T >::hasException(), folly::exception_wrapper::throw_exception(), type, and folly::Try< T >::value().

213  {
214  if (hasException()) {
216  }
217 }
bool hasException() const
Definition: Try.h:463
exception_wrapper e_
Definition: Try.h:584
std::exception* folly::Try< void >::tryGetExceptionObject ( )
inline

Definition at line 510 of file Try.h.

510  {
511  return hasException() ? e_.get_exception() : nullptr;
512  }
bool hasException() const
Definition: Try.h:463
std::exception * get_exception() noexcept
exception_wrapper e_
Definition: Try.h:584
std::exception const* folly::Try< void >::tryGetExceptionObject ( ) const
inline

Definition at line 513 of file Try.h.

513  {
514  return hasException() ? e_.get_exception() : nullptr;
515  }
bool hasException() const
Definition: Try.h:463
std::exception * get_exception() noexcept
exception_wrapper e_
Definition: Try.h:584
template<class E >
E* folly::Try< void >::tryGetExceptionObject ( )
inline

Definition at line 523 of file Try.h.

523  {
524  return hasException() ? e_.get_exception<E>() : nullptr;
525  }
bool hasException() const
Definition: Try.h:463
std::exception * get_exception() noexcept
exception_wrapper e_
Definition: Try.h:584
template<class E >
E const* folly::Try< void >::tryGetExceptionObject ( ) const
inline

Definition at line 527 of file Try.h.

527  {
528  return hasException() ? e_.get_exception<E>() : nullptr;
529  }
bool hasException() const
Definition: Try.h:463
std::exception * get_exception() noexcept
exception_wrapper e_
Definition: Try.h:584
void folly::Try< void >::value ( ) const
inline

Definition at line 447 of file Try.h.

Referenced by folly::coro::detail::BlockingWaitPromise< void >::get().

447  {
448  throwIfFailed();
449  }
void throwIfFailed() const
Definition: Try-inl.h:213
template<class Ex , class F >
bool folly::Try< void >::withException ( func)
inline

Definition at line 539 of file Try.h.

References folly::gen::move.

539  {
540  if (!hasException()) {
541  return false;
542  }
543  return e_.with_exception<Ex>(std::move(func));
544  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584
template<class Ex , class F >
bool folly::Try< void >::withException ( func) const
inline

Definition at line 546 of file Try.h.

References folly::gen::move.

546  {
547  if (!hasException()) {
548  return false;
549  }
550  return e_.with_exception<Ex>(std::move(func));
551  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584
template<class F >
bool folly::Try< void >::withException ( func)
inline

Definition at line 562 of file Try.h.

References folly::gen::move.

562  {
563  if (!hasException()) {
564  return false;
565  }
566  return e_.with_exception(std::move(func));
567  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584
template<class F >
bool folly::Try< void >::withException ( func) const
inline

Definition at line 569 of file Try.h.

References folly::gen::move.

569  {
570  if (!hasException()) {
571  return false;
572  }
573  return e_.with_exception(std::move(func));
574  }
bool hasException() const
Definition: Try.h:463
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
exception_wrapper e_
Definition: Try.h:584

Member Data Documentation

union { ... }

Definition at line 584 of file Try.h.

Referenced by Try().

bool folly::Try< void >::hasValue_
private

Definition at line 582 of file Try.h.


The documentation for this class was generated from the following files: