8#include <aws/core/Core_EXPORTS.h>
9#include <aws/core/utils/logging/LogMacros.h>
26 template<
typename R,
typename E>
31 Outcome() : result(), error(), success(false)
34 Outcome(
const R& r) : result(r), error(), success(true)
37 Outcome(
const E& e) : result(), error(e), success(false)
40 Outcome(R&& r) : result(std::forward<R>(r)), error(), success(true)
43 Outcome(E&& e) : result(), error(std::forward<E>(e)), success(false)
53 template<
typename RT,
typename ET>
56#if defined (__cplusplus) && __cplusplus > 201103L
57 template<
bool B,
class T =
void >
60 template<
bool B,
class T =
void >
65 template<typename RT, typename ET, enable_if_t<std::is_convertible<RT, R>::value &&
66 std::is_convertible<ET, E>::value,
int> = 0>
68 result(std::move(o.result)),
69 error(std::move(o.error)),
75 template<typename RT, typename ET, enable_if_t<std::is_convertible<RT, R>::value &&
76 !std::is_convertible<ET, E>::value,
int> = 0>
78 result(std::move(o.result)),
85 template<typename RT, typename ET, enable_if_t<!std::is_convertible<RT, R>::value &&
86 std::is_convertible<ET, E>::value,
int> = 0>
88 error(std::move(o.error)),
94 template<typename ET, enable_if_t<std::is_convertible<ET, E>::value,
int> = 0>
95 Outcome(ET&& e) : error(std::forward<ET>(e)), success(false)
106 retryCount = o.retryCount;
113 result(std::move(o.result)),
114 error(std::move(o.error)),
116 retryCount(std::move(o.retryCount))
124 result = std::move(o.result);
125 error = std::move(o.error);
127 retryCount = std::move(o.retryCount);
136 AWS_LOGSTREAM_FATAL(
OUTCOME_LOG_TAG,
"GetResult called on a failed outcome! Result is not initialized!");
144 AWS_LOGSTREAM_FATAL(
OUTCOME_LOG_TAG,
"GetResult called on a failed outcome! Result is not initialized!");
156 AWS_LOGSTREAM_FATAL(
OUTCOME_LOG_TAG,
"GetResult called on a failed outcome! Result is not initialized!");
158 return std::move(result);
164 AWS_LOGSTREAM_FATAL(
OUTCOME_LOG_TAG,
"GetError called on a success outcome! Error is not initialized!");
173 AWS_LOGSTREAM_FATAL(
OUTCOME_LOG_TAG,
"GetError called on a success outcome! Error is not initialized!");
175 return error.template GetModeledError<T>();
180 return this->success;
190 inline void SetRetryCount(
const unsigned int iRetryCount) { retryCount = iRetryCount; }
195 bool success =
false;
196 unsigned int retryCount = 0;
Outcome & operator=(Outcome &&o)
Outcome(Outcome< RT, ET > &&o)
const E & GetError() const
const R & GetResult() const
R && GetResultWithOwnership()
Outcome(const Outcome &o)
typename std::enable_if< B, T >::type enable_if_t
Outcome & operator=(const Outcome &o)
void SetRetryCount(const unsigned int iRetryCount)
unsigned int GetRetryCount() const
static const char OUTCOME_LOG_TAG[]