#include <glog/logging.h>
+#include <folly/CppAttributes.h>
#include <folly/Likely.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/Unit.h>
#include <folly/Utility.h>
+#include <folly/lang/ColdClass.h>
#define FOLLY_EXPECTED_ID(X) FB_CONCATENATE(FB_CONCATENATE(Folly, X), __LINE__)
* Expected objects in the error state.
*/
template <class Error>
-class Unexpected final {
+class Unexpected final : ColdClass {
template <class E>
friend class Unexpected;
template <class V, class E>
* Accessors
*/
constexpr bool hasValue() const noexcept {
- return expected_detail::Which::eValue == this->which_;
+ return LIKELY(expected_detail::Which::eValue == this->which_);
}
constexpr bool hasError() const noexcept {
- return expected_detail::Which::eError == this->which_;
+ return UNLIKELY(expected_detail::Which::eError == this->which_);
}
using Base::uninitializedByException;
}
} // namespace folly
-// This makes folly::Optional<Value> useable as a coroutine return type..
-FOLLY_NAMESPACE_STD_BEGIN
+// This makes folly::Expected<Value> useable as a coroutine return type...
+namespace std {
namespace experimental {
template <typename Value, typename Error, typename... Args>
struct coroutine_traits<folly::Expected<Value, Error>, Args...> {
using promise_type = folly::expected_detail::Promise<Value, Error>;
};
} // namespace experimental
-FOLLY_NAMESPACE_STD_END
+} // namespace std
#endif // FOLLY_HAS_COROUTINES