proxygen
folly::MoveWrapper< T > Class Template Reference

#include <MoveWrapper.h>

Public Member Functions

 MoveWrapper ()=default
 
 MoveWrapper (T &&t)
 Move a value in. More...
 
 MoveWrapper (const MoveWrapper &other)
 copy is move More...
 
 MoveWrapper (MoveWrapper &&other)
 move is also move More...
 
const Toperator* () const
 
Toperator* ()
 
const Toperator-> () const
 
Toperator-> ()
 
T && move ()
 move the value out (sugar for std::move(*moveWrapper)) More...
 
MoveWrapperoperator= (MoveWrapper const &)=delete
 
MoveWrapperoperator= (MoveWrapper &&)=delete
 

Private Attributes

T value
 

Detailed Description

template<class T>
class folly::MoveWrapper< T >

C++11 closures don't support move-in capture. Nor does std::bind. facepalm.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3610.html

"[...] a work-around that should make people's stomach crawl: write a wrapper that performs move-on-copy, much like the deprecated auto_ptr"

Unlike auto_ptr, this doesn't require a heap allocation.

Definition at line 35 of file MoveWrapper.h.

Constructor & Destructor Documentation

template<class T>
folly::MoveWrapper< T >::MoveWrapper ( )
default

If value can be default-constructed, why not? Then we don't have to move it in

template<class T>
folly::MoveWrapper< T >::MoveWrapper ( T &&  t)
inlineexplicit

Move a value in.

Definition at line 42 of file MoveWrapper.h.

42 : value(std::move(t)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T>
folly::MoveWrapper< T >::MoveWrapper ( const MoveWrapper< T > &  other)
inline

copy is move

Definition at line 45 of file MoveWrapper.h.

45 : value(std::move(other.value)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T>
folly::MoveWrapper< T >::MoveWrapper ( MoveWrapper< T > &&  other)
inline

move is also move

Definition at line 48 of file MoveWrapper.h.

48 : value(std::move(other.value)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class T>
T&& folly::MoveWrapper< T >::move ( )
inline

move the value out (sugar for std::move(*moveWrapper))

Definition at line 65 of file MoveWrapper.h.

References folly::gen::move, folly::MoveWrapper< T >::operator=(), and folly::MoveWrapper< T >::value.

65  {
66  return std::move(value);
67  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T>
const T& folly::MoveWrapper< T >::operator* ( ) const
inline

Definition at line 50 of file MoveWrapper.h.

References folly::MoveWrapper< T >::value.

50  {
51  return value;
52  }
template<class T>
T& folly::MoveWrapper< T >::operator* ( )
inline

Definition at line 53 of file MoveWrapper.h.

References folly::MoveWrapper< T >::value.

53  {
54  return value;
55  }
template<class T>
const T* folly::MoveWrapper< T >::operator-> ( ) const
inline

Definition at line 57 of file MoveWrapper.h.

References folly::MoveWrapper< T >::value.

57  {
58  return &value;
59  }
template<class T>
T* folly::MoveWrapper< T >::operator-> ( )
inline

Definition at line 60 of file MoveWrapper.h.

References folly::MoveWrapper< T >::value.

60  {
61  return &value;
62  }
template<class T>
MoveWrapper& folly::MoveWrapper< T >::operator= ( MoveWrapper< T > const &  )
delete
template<class T>
MoveWrapper& folly::MoveWrapper< T >::operator= ( MoveWrapper< T > &&  )
delete

Member Data Documentation

template<class T>
T folly::MoveWrapper< T >::value
mutableprivate

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