proxygen
folly::pushmi::detail::opt< T > Struct Template Reference

#include <opt.h>

Public Member Functions

 opt ()=default
 
 opt (T &&t) noexcept(std::is_nothrow_move_constructible< T >::value)
 
 opt (const T &t)
 
 opt (opt &&that) noexcept(std::is_nothrow_move_constructible< T >::value)
 
 opt (const opt &that)
 
 ~opt ()
 
optoperator= (opt &&that) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
 
optoperator= (const opt &that)
 
optoperator= (T &&t) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
 
optoperator= (const T &t)
 
 operator bool () const noexcept
 
Toperator* () noexcept
 
const Toperator* () const noexcept
 

Private Member Functions

Tptr ()
 
const Tptr () const
 
void reset ()
 

Private Attributes

bool empty_ = true
 
std::aligned_union_t< 0, Tdata_
 

Detailed Description

template<class T>
struct folly::pushmi::detail::opt< T >

Definition at line 39 of file opt.h.

Constructor & Destructor Documentation

template<class T>
folly::pushmi::detail::opt< T >::opt ( T &&  t)
inlinenoexcept

Definition at line 58 of file opt.h.

58  {
59  ::new (ptr()) T(std::move(t));
60  empty_ = false;
61  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
folly::std T
template<class T>
folly::pushmi::detail::opt< T >::opt ( const T t)
inline

Definition at line 62 of file opt.h.

62  {
63  ::new (ptr()) T(t);
64  empty_ = false;
65  }
folly::std T
template<class T>
folly::pushmi::detail::opt< T >::opt ( opt< T > &&  that)
inlinenoexcept

Definition at line 66 of file opt.h.

66  {
67  if (that) {
68  ::new (ptr()) T(std::move(*that));
69  empty_ = false;
70  that.reset();
71  }
72  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
folly::std T
template<class T>
folly::pushmi::detail::opt< T >::opt ( const opt< T > &  that)
inline

Definition at line 73 of file opt.h.

73  {
74  if (that) {
75  ::new (ptr()) T(*that);
76  empty_ = false;
77  }
78  }
folly::std T
template<class T>
folly::pushmi::detail::opt< T >::~opt ( )
inline

Definition at line 79 of file opt.h.

79  {
80  reset();
81  }

Member Function Documentation

template<class T>
folly::pushmi::detail::opt< T >::operator bool ( ) const
inlineexplicitnoexcept

Definition at line 127 of file opt.h.

127  {
128  return !empty_;
129  }
template<class T>
T& folly::pushmi::detail::opt< T >::operator* ( )
inlinenoexcept

Definition at line 130 of file opt.h.

130  {
131  return *ptr();
132  }
template<class T>
const T& folly::pushmi::detail::opt< T >::operator* ( ) const
inlinenoexcept

Definition at line 133 of file opt.h.

133  {
134  return *ptr();
135  }
template<class T>
opt& folly::pushmi::detail::opt< T >::operator= ( opt< T > &&  that)
inlinenoexcept

Definition at line 82 of file opt.h.

84  {
85  if (*this && that) {
86  **this = std::move(*that);
87  that.reset();
88  } else if (*this) {
89  reset();
90  } else if (that) {
91  ::new (ptr()) T(std::move(*that));
92  empty_ = false;
93  }
94  return *this;
95  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
folly::std T
template<class T>
opt& folly::pushmi::detail::opt< T >::operator= ( const opt< T > &  that)
inline

Definition at line 96 of file opt.h.

96  {
97  if (*this && that) {
98  **this = *that;
99  } else if (*this) {
100  reset();
101  } else if (that) {
102  ::new (ptr()) T(*that);
103  empty_ = false;
104  }
105  return *this;
106  }
folly::std T
template<class T>
opt& folly::pushmi::detail::opt< T >::operator= ( T &&  t)
inlinenoexcept

Definition at line 107 of file opt.h.

109  {
110  if (*this)
111  **this = std::move(t);
112  else {
113  ::new (ptr()) T(std::move(t));
114  empty_ = false;
115  }
116  return *this;
117  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
folly::std T
template<class T>
opt& folly::pushmi::detail::opt< T >::operator= ( const T t)
inline

Definition at line 118 of file opt.h.

118  {
119  if (*this)
120  **this = t;
121  else {
122  ::new (ptr()) T(t);
123  empty_ = false;
124  }
125  return *this;
126  }
folly::std T
template<class T>
const T* folly::pushmi::detail::opt< T >::ptr ( ) const
inlineprivate

Definition at line 46 of file opt.h.

46  {
47  return static_cast<const T*>((const void*)&data_);
48  }
folly::std T
std::aligned_union_t< 0, T > data_
Definition: opt.h:42
template<class T>
void folly::pushmi::detail::opt< T >::reset ( )
inlineprivate

Member Data Documentation

template<class T>
std::aligned_union_t<0, T> folly::pushmi::detail::opt< T >::data_
private

Definition at line 42 of file opt.h.

template<class T>
bool folly::pushmi::detail::opt< T >::empty_ = true
private

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