X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FLazy.h;h=ff115f3f3d3af233e35bada0678546385e399f87;hp=bca89d9ab529d1ce484dcd5980f80b1a51d78c9c;hb=67300dac6ed429facd7c6f5e03b7c245e32f8383;hpb=275ca94d04e44f28cfa411668eb1c1dd8db90b80 diff --git a/folly/Lazy.h b/folly/Lazy.h index bca89d9a..ff115f3f 100644 --- a/folly/Lazy.h +++ b/folly/Lazy.h @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef FOLLY_LAZY_H_ -#define FOLLY_LAZY_H_ -#include +#pragma once + #include +#include #include @@ -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,6 +132,4 @@ lazy(Func&& fun) { ////////////////////////////////////////////////////////////////////// -} - -#endif +} // namespace folly