X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FLazy.h;h=ff115f3f3d3af233e35bada0678546385e399f87;hb=eb7bc45f22e034751a76bf02445c669471e60780;hp=32723bc1053694188580736f05fe6f74b97b428f;hpb=520e20a8baebc98a5ec84d67865da4cf9819f88a;p=folly.git diff --git a/folly/Lazy.h b/folly/Lazy.h index 32723bc1..ff115f3f 100644 --- a/folly/Lazy.h +++ b/folly/Lazy.h @@ -86,7 +86,7 @@ namespace folly { namespace detail { -template +template struct Lazy { typedef typename std::result_of::type result_type; @@ -107,20 +107,22 @@ struct Lazy { } result_type& operator()() { - if (!value_) value_ = func_(); + if (!value_) { + value_ = func_(); + } return *value_; } -private: + private: Optional value_; Func func_; }; -} +} // namespace detail ////////////////////////////////////////////////////////////////////// -template +template detail::Lazy::type> lazy(Func&& fun) { return detail::Lazy::type>( @@ -130,4 +132,4 @@ lazy(Func&& fun) { ////////////////////////////////////////////////////////////////////// -} +} // namespace folly