proxygen
folly::detail::Lazy< Func > Struct Template Reference

#include <Lazy.h>

Public Types

typedef invoke_result_t< Funcresult_type
 

Public Member Functions

 Lazy (Func &&f)
 
 Lazy (const Func &f)
 
 Lazy (Lazy &&o)
 
 Lazy (const Lazy &)=delete
 
Lazyoperator= (const Lazy &)=delete
 
Lazyoperator= (Lazy &&)=delete
 
const result_typeoperator() () const
 
result_typeoperator() ()
 

Private Member Functions

void ensure_initialized () const
 

Private Attributes

Optional< result_typevalue_
 
Func func_
 

Detailed Description

template<class Func>
struct folly::detail::Lazy< Func >

Definition at line 91 of file Lazy.h.

Member Typedef Documentation

template<class Func >
typedef invoke_result_t<Func> folly::detail::Lazy< Func >::result_type

Definition at line 92 of file Lazy.h.

Constructor & Destructor Documentation

template<class Func >
folly::detail::Lazy< Func >::Lazy ( Func &&  f)
inlineexplicit

Definition at line 101 of file Lazy.h.

Referenced by folly::detail::Lazy< Func >::Lazy().

101 : func_(std::move(f)) {}
auto f
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class Func >
folly::detail::Lazy< Func >::Lazy ( const Func f)
inlineexplicit

Definition at line 102 of file Lazy.h.

102 : func_(f) {}
auto f
template<class Func >
folly::detail::Lazy< Func >::Lazy ( Lazy< Func > &&  o)
inline

Definition at line 104 of file Lazy.h.

References folly::detail::Lazy< Func >::Lazy(), and folly::detail::Lazy< Func >::operator=().

104 : value_(std::move(o.value_)), func_(std::move(o.func_)) {}
Optional< result_type > value_
Definition: Lazy.h:129
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class Func >
folly::detail::Lazy< Func >::Lazy ( const Lazy< Func > &  )
delete

Member Function Documentation

template<class Func >
void folly::detail::Lazy< Func >::ensure_initialized ( ) const
inlineprivate

Definition at line 123 of file Lazy.h.

References folly::detail::Lazy< Func >::func_, and folly::detail::Lazy< Func >::value_.

Referenced by folly::detail::Lazy< Func >::operator()().

123  {
124  if (!value_) {
125  value_ = func_();
126  }
127  }
Optional< result_type > value_
Definition: Lazy.h:129
template<class Func >
const result_type& folly::detail::Lazy< Func >::operator() ( ) const
inline

Definition at line 110 of file Lazy.h.

References folly::detail::Lazy< Func >::ensure_initialized(), and folly::detail::Lazy< Func >::value_.

110  {
112 
113  return *value_;
114  }
Optional< result_type > value_
Definition: Lazy.h:129
void ensure_initialized() const
Definition: Lazy.h:123
template<class Func >
result_type& folly::detail::Lazy< Func >::operator() ( )
inline

Definition at line 116 of file Lazy.h.

References folly::detail::Lazy< Func >::ensure_initialized(), and folly::detail::Lazy< Func >::value_.

116  {
118 
119  return *value_;
120  }
Optional< result_type > value_
Definition: Lazy.h:129
void ensure_initialized() const
Definition: Lazy.h:123
template<class Func >
Lazy& folly::detail::Lazy< Func >::operator= ( const Lazy< Func > &  )
delete
template<class Func >
Lazy& folly::detail::Lazy< Func >::operator= ( Lazy< Func > &&  )
delete

Member Data Documentation

template<class Func >
Func folly::detail::Lazy< Func >::func_
mutableprivate

Definition at line 130 of file Lazy.h.

Referenced by folly::detail::Lazy< Func >::ensure_initialized().

template<class Func >
Optional<result_type> folly::detail::Lazy< Func >::value_
mutableprivate

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