X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FLazy.h;h=a4fcfd359810be170a731aaa997039845d3b0af0;hb=44dcd737f7e77320d8d1380e483f93a82dc9a970;hp=786f51c6ac0e9b3807b77b6430f25aeb8509dd6e;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930;p=folly.git diff --git a/folly/Lazy.h b/folly/Lazy.h index 786f51c6..a4fcfd35 100644 --- a/folly/Lazy.h +++ b/folly/Lazy.h @@ -16,8 +16,8 @@ #pragma once -#include #include +#include #include @@ -86,7 +86,7 @@ namespace folly { namespace detail { -template +template struct Lazy { typedef typename std::result_of::type result_type; @@ -107,11 +107,13 @@ struct Lazy { } result_type& operator()() { - if (!value_) value_ = func_(); + if (!value_) { + value_ = func_(); + } return *value_; } -private: + private: Optional value_; Func func_; }; @@ -120,7 +122,7 @@ private: ////////////////////////////////////////////////////////////////////// -template +template detail::Lazy::type> lazy(Func&& fun) { return detail::Lazy::type>(