* limitations under the License.
*/
-#ifndef FOLLY_OPTIONAL_H_
-#define FOLLY_OPTIONAL_H_
+#pragma once
/*
* Optional - For conditional initialization of values, like boost::optional,
* }
*/
#include <cstddef>
+#include <new>
#include <stdexcept>
#include <type_traits>
#include <utility>
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);
}
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(); }
///////////////////////////////////////////////////////////////////////////////
} // namespace folly
-
-#endif // FOLLY_OPTIONAL_H_