proxygen
folly::Indestructible< T > Class Template Referencefinal

#include <Indestructible.h>

Classes

union  Storage
 

Public Member Functions

template<typename S = T, typename = decltype(S())>
constexpr Indestructible () noexcept(noexcept(T()))
 
template<typename U = T, _t< std::enable_if< std::is_constructible< T, U && >::value >> * = nullptr, _t< std::enable_if< !std::is_same< Indestructible< T >, remove_cvref_t< U >>::value >> * = nullptr, _t< std::enable_if<!std::is_convertible< U &&, T >::value >> * = nullptr>
constexpr Indestructible (U &&u) noexcept(noexcept(T(std::declval< U >())))
 
template<typename U = T, _t< std::enable_if< std::is_constructible< T, U && >::value >> * = nullptr, _t< std::enable_if< !std::is_same< Indestructible< T >, remove_cvref_t< U >>::value >> * = nullptr, _t< std::enable_if< std::is_convertible< U &&, T >::value >> * = nullptr>
constexpr Indestructible (U &&u) noexcept(noexcept(T(std::declval< U >())))
 
template<typename... Args, typename = decltype(T(std::declval<Args>()...))>
constexpr Indestructible (Args &&...args) noexcept(noexcept(T(std::declval< Args >()...)))
 
template<typename U , typename... Args, typename = decltype( T(std::declval<std::initializer_list<U>&>(), std::declval<Args>()...))>
constexpr Indestructible (std::initializer_list< U > il, Args...args) noexcept(noexcept(T(std::declval< std::initializer_list< U > & >(), std::declval< Args >()...)))
 
 ~Indestructible ()=default
 
 Indestructible (Indestructible const &)=delete
 
Indestructibleoperator= (Indestructible const &)=delete
 
 Indestructible (Indestructible &&other) noexcept(noexcept(T(std::declval< T >())))
 
Indestructibleoperator= (Indestructible &&other) noexcept(noexcept(T(std::declval< T >())))
 
Tget () noexcept
 
T const * get () const noexcept
 
Toperator* () noexcept
 
T const & operator* () const noexcept
 
Toperator-> () noexcept
 
T const * operator-> () const noexcept
 

Private Member Functions

void check () const noexcept
 

Private Attributes

Storage storage_ {}
 
bool erased_ {false}
 

Detailed Description

template<typename T>
class folly::Indestructible< T >

Definition at line 61 of file Indestructible.h.

Constructor & Destructor Documentation

template<typename T>
template<typename S = T, typename = decltype(S())>
constexpr folly::Indestructible< T >::Indestructible ( )
inlinenoexcept

Definition at line 64 of file Indestructible.h.

References folly::T, and folly::value().

Referenced by folly::Indestructible< T >::Indestructible().

64 {}
template<typename T>
template<typename U = T, _t< std::enable_if< std::is_constructible< T, U && >::value >> * = nullptr, _t< std::enable_if< !std::is_same< Indestructible< T >, remove_cvref_t< U >>::value >> * = nullptr, _t< std::enable_if<!std::is_convertible< U &&, T >::value >> * = nullptr>
constexpr folly::Indestructible< T >::Indestructible ( U &&  u)
inlineexplicitnoexcept

Constructor accepting a single argument by forwarding reference, this allows using list initialzation without the overhead of things like in_place, etc and also works with std::initializer_list constructors which can't be deduced, the default parameter helps there.

auto i = folly::Indestructible<std::map<int, int>>{{{1, 2}}};

This provides convenience

There are two versions of this constructor - one for when the element is implicitly constructible from the given argument and one for when the type is explicitly but not implicitly constructible from the given argument.

Definition at line 88 of file Indestructible.h.

References folly::T.

90  : storage_(std::forward<U>(u)) {}
template<typename T>
template<typename U = T, _t< std::enable_if< std::is_constructible< T, U && >::value >> * = nullptr, _t< std::enable_if< !std::is_same< Indestructible< T >, remove_cvref_t< U >>::value >> * = nullptr, _t< std::enable_if< std::is_convertible< U &&, T >::value >> * = nullptr>
constexpr folly::Indestructible< T >::Indestructible ( U &&  u)
inlinenoexcept

Definition at line 98 of file Indestructible.h.

References testing::Args(), and folly::T.

100  : storage_(std::forward<U>(u)) {}
template<typename T>
template<typename... Args, typename = decltype(T(std::declval<Args>()...))>
constexpr folly::Indestructible< T >::Indestructible ( Args &&...  args)
inlineexplicitnoexcept

Definition at line 103 of file Indestructible.h.

References testing::Args(), and folly::T.

105  : storage_(std::forward<Args>(args)...) {}
template<typename T>
template<typename U , typename... Args, typename = decltype( T(std::declval<std::initializer_list<U>&>(), std::declval<Args>()...))>
constexpr folly::Indestructible< T >::Indestructible ( std::initializer_list< U >  il,
Args...  args 
)
inlineexplicitnoexcept
template<typename T>
folly::Indestructible< T >::~Indestructible ( )
default
template<typename T>
folly::Indestructible< T >::Indestructible ( Indestructible< T > const &  )
delete
template<typename T>
folly::Indestructible< T >::Indestructible ( Indestructible< T > &&  other)
inlinenoexcept

Definition at line 123 of file Indestructible.h.

125  : storage_(std::move(other.storage_.value)) {
126  other.erased_ = true;
127  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<typename T>
void folly::Indestructible< T >::check ( ) const
inlineprivatenoexcept

Definition at line 156 of file Indestructible.h.

References folly::Indestructible< T >::erased_.

Referenced by folly::Indestructible< T >::get().

156  {
157  assert(!erased_);
158  }
template<typename T>
T* folly::Indestructible< T >::get ( )
inlinenoexcept
template<typename T>
T const* folly::Indestructible< T >::get ( ) const
inlinenoexcept
template<typename T>
T& folly::Indestructible< T >::operator* ( )
inlinenoexcept

Definition at line 142 of file Indestructible.h.

142  {
143  return *get();
144  }
template<typename T>
T const& folly::Indestructible< T >::operator* ( ) const
inlinenoexcept

Definition at line 145 of file Indestructible.h.

145  {
146  return *get();
147  }
template<typename T>
T* folly::Indestructible< T >::operator-> ( )
inlinenoexcept

Definition at line 148 of file Indestructible.h.

148  {
149  return get();
150  }
template<typename T>
T const* folly::Indestructible< T >::operator-> ( ) const
inlinenoexcept

Definition at line 151 of file Indestructible.h.

151  {
152  return get();
153  }
template<typename T>
Indestructible& folly::Indestructible< T >::operator= ( Indestructible< T > const &  )
delete
template<typename T>
Indestructible& folly::Indestructible< T >::operator= ( Indestructible< T > &&  other)
inlinenoexcept

Definition at line 128 of file Indestructible.h.

References folly::gen::move, folly::Indestructible< T >::storage_, and folly::Indestructible< T >::Storage::value.

129  {
130  storage_.value = std::move(other.storage_.value);
131  other.erased_ = true;
132  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Data Documentation

template<typename T>
bool folly::Indestructible< T >::erased_ {false}
private

Definition at line 175 of file Indestructible.h.

Referenced by folly::Indestructible< T >::check().

template<typename T>
Storage folly::Indestructible< T >::storage_ {}
private

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