Adds unbounded queue test case
[folly.git] / folly / Expected.h
index f15010dfe821600c58c1221e6739870b743af1f5..4b736c6b9b63a0b8f384715ebc6ef9946b0d9d7e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2016-present 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,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
  * Like folly::Optional, but can store a value *or* an error.
  *
@@ -31,6 +30,8 @@
 
 #include <glog/logging.h>
 
+#include <folly/CPortability.h>
+#include <folly/CppAttributes.h>
 #include <folly/Likely.h>
 #include <folly/Optional.h>
 #include <folly/Portability.h>
@@ -38,6 +39,7 @@
 #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__)
 
@@ -658,7 +660,7 @@ inline expected_detail::UnexpectedTag unexpected(
 /**
  * An exception type thrown by Expected on catastrophic logic errors.
  */
-class BadExpectedAccess : public std::logic_error {
+class FOLLY_EXPORT BadExpectedAccess : public std::logic_error {
  public:
   BadExpectedAccess() : std::logic_error("bad Expected access") {}
 };
@@ -674,7 +676,7 @@ namespace expected_detail {
  * 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>
@@ -687,7 +689,7 @@ class Unexpected final {
    * when the user tries to access the nested value but the Expected object is
    * actually storing an error code.
    */
-  class BadExpectedAccess : public folly::BadExpectedAccess {
+  class FOLLY_EXPORT BadExpectedAccess : public folly::BadExpectedAccess {
    public:
     explicit BadExpectedAccess(Error err)
         : folly::BadExpectedAccess{}, error_(std::move(err)) {}
@@ -1517,13 +1519,13 @@ expected_detail::Awaitable<Value, Error>
 }
 } // 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