proxygen
Expected.h File Reference
#include <cstddef>
#include <initializer_list>
#include <new>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <folly/CPortability.h>
#include <folly/CppAttributes.h>
#include <folly/Likely.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/Preprocessor.h>
#include <folly/Traits.h>
#include <folly/Unit.h>
#include <folly/Utility.h>
#include <folly/lang/ColdClass.h>
#include <folly/lang/Exception.h>

Go to the source code of this file.

Classes

class  folly::Unexpected< Error >
 
class  folly::Expected< Value, Error >
 
struct  folly::expected_detail::PromiseReturn< Value, Error >
 
struct  folly::expected_detail::EmptyTag
 
struct  folly::expected_detail::ValueTag
 
struct  folly::expected_detail::ErrorTag
 
struct  folly::expected_detail::ExpectedStorage< Value, Error, StorageType >
 
struct  folly::expected_detail::ExpectedUnion< Value, Error >
 
struct  folly::expected_detail::CopyConstructible< Derived, bool, Noexcept >
 
struct  folly::expected_detail::CopyConstructible< Derived, false, Noexcept >
 
struct  folly::expected_detail::MoveConstructible< Derived, bool, Noexcept >
 
struct  folly::expected_detail::MoveConstructible< Derived, false, Noexcept >
 
struct  folly::expected_detail::CopyAssignable< Derived, bool, Noexcept >
 
struct  folly::expected_detail::CopyAssignable< Derived, false, Noexcept >
 
struct  folly::expected_detail::MoveAssignable< Derived, bool, Noexcept >
 
struct  folly::expected_detail::MoveAssignable< Derived, false, Noexcept >
 
struct  folly::expected_detail::ExpectedStorage< Value, Error, StorageType::eUnion >
 
struct  folly::expected_detail::ExpectedStorage< Value, Error, StorageType::ePODStruct >
 
struct  folly::expected_detail::expected_detail_ExpectedHelper::ExpectedHelper
 
struct  folly::expected_detail::UnexpectedTag
 
class  folly::BadExpectedAccess
 
class  folly::Unexpected< Error >
 
class  folly::Unexpected< Error >::BadExpectedAccess
 
struct  folly::Unexpected< Error >::MakeBadExpectedAccess
 
class  folly::Expected< Value, Error >
 

Namespaces

 folly
 —— Concurrent Priority Queue Implementation ——
 
 folly::expected_detail
 
 folly::expected_detail::expected_detail_ExpectedHelper
 

Macros

#define FOLLY_EXPECTED_ID(X)   FB_CONCATENATE(FB_CONCATENATE(Folly, X), __LINE__)
 
#define FOLLY_REQUIRES_IMPL(...)
 
#define FOLLY_REQUIRES_TRAILING(...)   , FOLLY_REQUIRES_IMPL(__VA_ARGS__)
 
#define FOLLY_REQUIRES(...)   template <FOLLY_REQUIRES_IMPL(__VA_ARGS__)>
 

Typedefs

template<class Expected >
using folly::ExpectedValueType = typename std::remove_reference< Expected >::type::value_type
 
template<class Expected >
using folly::ExpectedErrorType = typename std::remove_reference< Expected >::type::error_type
 
template<template< class... > class Trait, class... Ts>
using folly::expected_detail::StrictAllOf = StrictConjunction< Trait< Ts >... >
 
template<class T >
using folly::expected_detail::IsCopyable = StrictConjunction< std::is_copy_constructible< T >, std::is_copy_assignable< T >>
 
template<class T >
using folly::expected_detail::IsMovable = StrictConjunction< std::is_move_constructible< T >, std::is_move_assignable< T >>
 
template<class T >
using folly::expected_detail::IsNothrowCopyable = StrictConjunction< std::is_nothrow_copy_constructible< T >, std::is_nothrow_copy_assignable< T >>
 
template<class T >
using folly::expected_detail::IsNothrowMovable = StrictConjunction< std::is_nothrow_move_constructible< T >, std::is_nothrow_move_assignable< T >>
 
template<class From , class To >
using folly::expected_detail::IsConvertible = StrictConjunction< std::is_constructible< To, From >, std::is_assignable< To &, From >>
 
using folly::unexpected_t = expected_detail::UnexpectedTag(&)(expected_detail::UnexpectedTag)
 

Enumerations

enum  folly::expected_detail::Which : unsigned char { folly::expected_detail::Which::eEmpty, folly::expected_detail::Which::eValue, folly::expected_detail::Which::eError }
 
enum  folly::expected_detail::StorageType { folly::expected_detail::StorageType::ePODStruct, folly::expected_detail::StorageType::ePODUnion, folly::expected_detail::StorageType::eUnion }
 

Functions

template<class Error >
constexpr Unexpected< typename std::decay< Error >::typefolly::makeUnexpected (Error &&)
 
template<class Error , class Value >
constexpr Expected< typename std::decay< Value >::type, Errorfolly::makeExpected (Value &&)
 
template<class T , class U >
auto folly::expected_detail::doEmplaceAssign (int, T &t, U &&u) -> decltype(void(t=static_cast< U && >(u)))
 
template<class T , class U >
auto folly::expected_detail::doEmplaceAssign (long, T &t, U &&u) -> decltype(void(T(static_cast< U && >(u))))
 
template<class T , class... Us>
auto folly::expected_detail::doEmplaceAssign (int, T &t, Us &&...us) -> decltype(void(t=T(static_cast< Us && >(us)...)))
 
template<class T , class... Us>
auto folly::expected_detail::doEmplaceAssign (long, T &t, Us &&...us) -> decltype(void(T(static_cast< Us && >(us)...)))
 
template<class Value , class Error >
constexpr StorageType folly::expected_detail::getStorageType ()
 
template<class T >
T && folly::expected_detail::expected_detail_ExpectedHelper::operator, (T &&t, Unit) noexcept
 
expected_detail::UnexpectedTag folly::unexpected (expected_detail::UnexpectedTag={})
 
template<class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsEqualityComparable< Error >::value)), int >::type = 0>
bool folly::operator== (const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
 
template<class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsEqualityComparable< Error >::value)), int >::type = 0>
bool folly::operator!= (const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
 
template<class Value , class Error >
std::enable_if< IsEqualityComparable< Value >::value, bool >::type folly::operator== (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsEqualityComparable< Value >::value)), int >::type = 0>
bool folly::operator!= (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error >
std::enable_if< IsLessThanComparable< Value >::value, bool >::type folly::operator< (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsLessThanComparable< Value >::value)), int >::type = 0>
bool folly::operator<= (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsLessThanComparable< Value >::value)), int >::type = 0>
bool folly::operator> (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error , bool FB_CONCATENATE = false, typename std::enable_if< (FB_CONCATENATE(FB_CONCATENATE(Folly, Requires), __LINE__)||static_cast< bool >(IsLessThanComparable< Value >::value)), int >::type = 0>
bool folly::operator>= (const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
 
template<class Value , class Error >
void folly::swap (Expected< Value, Error > &lhs, Expected< Value, Error > &rhs) noexcept(expected_detail::StrictAllOf< IsNothrowSwappable, Value, Error >::value)
 
template<class Value , class Error >
const Value * folly::get_pointer (const Expected< Value, Error > &ex) noexcept
 
template<class Value , class Error >
Value * folly::get_pointer (Expected< Value, Error > &ex) noexcept
 
template<class Value , class Error >
bool folly::operator== (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator!= (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator< (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator<= (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator>= (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator> (const Expected< Value, Error > &, const Value &other)=delete
 
template<class Value , class Error >
bool folly::operator== (const Value &other, const Expected< Value, Error > &)=delete
 
template<class Value , class Error >
bool folly::operator!= (const Value &other, const Expected< Value, Error > &)=delete
 
template<class Value , class Error >
bool folly::operator< (const Value &other, const Expected< Value, Error > &)=delete
 
template<class Value , class Error >
bool folly::operator<= (const Value &other, const Expected< Value, Error > &)=delete
 
template<class Value , class Error >
bool folly::operator>= (const Value &other, const Expected< Value, Error > &)=delete
 
template<class Value , class Error >
bool folly::operator> (const Value &other, const Expected< Value, Error > &)=delete
 

Macro Definition Documentation

#define FOLLY_EXPECTED_ID (   X)    FB_CONCATENATE(FB_CONCATENATE(Folly, X), __LINE__)

Like folly::Optional, but can store a value or an error.

Author
Eric Niebler (enieb.nosp@m.ler@.nosp@m.fb.co.nosp@m.m)

Definition at line 43 of file Expected.h.

#define FOLLY_REQUIRES (   ...)    template <FOLLY_REQUIRES_IMPL(__VA_ARGS__)>
#define FOLLY_REQUIRES_IMPL (   ...)
Value:
bool FOLLY_EXPECTED_ID(Requires) = false, \
typename std::enable_if< \
(FOLLY_EXPECTED_ID(Requires) || static_cast<bool>(__VA_ARGS__)), \
int>::type = 0
#define FOLLY_EXPECTED_ID(X)
Definition: Expected.h:43
PskType type

Definition at line 45 of file Expected.h.