namespace detail {
-template<class Func>
+template <class Func>
struct Lazy {
typedef typename std::result_of<Func()>::type result_type;
}
result_type& operator()() {
- if (!value_) value_ = func_();
+ if (!value_) {
+ value_ = func_();
+ }
return *value_;
}
-private:
+ private:
Optional<result_type> value_;
Func func_;
};
-}
+} // namespace detail
//////////////////////////////////////////////////////////////////////
-template<class Func>
+template <class Func>
detail::Lazy<typename std::remove_reference<Func>::type>
lazy(Func&& fun) {
return detail::Lazy<typename std::remove_reference<Func>::type>(
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly