Added a better check for openssl
[folly.git] / folly / Optional.h
index 2e04e332d0f55f6d15f8710764af0baf4385f9c1..e897c38bfb0ed91836be732cabe5d0716162107d 100644 (file)
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef FOLLY_OPTIONAL_H_
-#define FOLLY_OPTIONAL_H_
+#pragma once
 
 /*
  * Optional - For conditional initialization of values, like boost::optional,
@@ -55,6 +54,7 @@
  *  }
  */
 #include <cstddef>
+#include <new>
 #include <stdexcept>
 #include <type_traits>
 #include <utility>
@@ -206,7 +206,12 @@ class Optional {
     return storage_.value;
   }
 
-  Value value() && {
+  Value&& value() && {
+    require_value();
+    return std::move(storage_.value);
+  }
+
+  const Value&& value() const&& {
     require_value();
     return std::move(storage_.value);
   }
@@ -225,9 +230,10 @@ class Optional {
     return hasValue();
   }
 
-  const Value& operator*() const&  { return value(); }
-        Value& operator*()      &  { return value(); }
-        Value  operator*()      && { return std::move(value()); }
+  const Value& operator*()  const&  { return value(); }
+        Value& operator*()       &  { return value(); }
+  const Value&& operator*() const&& { return std::move(value()); }
+        Value&& operator*()      && { return std::move(value()); }
 
   const Value* operator->() const { return &value(); }
         Value* operator->()       { return &value(); }
@@ -406,5 +412,3 @@ template<class V> bool operator> (const V& other, const Optional<V>&) = delete;
 ///////////////////////////////////////////////////////////////////////////////
 
 } // namespace folly
-
-#endif // FOLLY_OPTIONAL_H_