CppWAMP
C++11 client library for the WAMP protocol
|
Go to the documentation of this file.
7 #ifndef CPPWAMP_ERROROR_HPP
8 #define CPPWAMP_ERROROR_HPP
17 #include <system_error>
63 swap(error_, other.error_);
72 template <
typename E1,
typename E2>
80 template <
typename E1,
typename E2>
90 noexcept(noexcept(x.swap(y)))
112 template <
typename TErrorEnum>
127 template <
typename T>
145 : value_(std::move(value)),
150 template <
typename G>
152 : error_(std::move(unex).value()),
158 template <
typename... Args>
161 value_ =
value_type(std::forward<Args>(args)...);
176 value_ = std::move(value);
183 template <
typename G>
194 noexcept(std::is_nothrow_swappable<value_type>::value)
197 swap(value_, rhs.value_);
198 swap(error_, rhs.error_);
199 swap(hasError_, rhs.hasError_);
206 return std::addressof(value_);
213 return std::addressof(value_);
229 return std::move(value_);
245 return std::move(value_);
249 explicit operator bool() const noexcept {
return has_value();}
269 return std::move(value_);
287 return std::move(value_);
294 assert(!has_value());
302 assert(!has_value());
307 template <
typename U>
313 return std::forward<U>(v);
318 template <
typename U>
322 return std::move(value_);
324 return std::forward<U>(v);
334 CPPWAMP_DEPRECATED
ErrorOr(std::error_code ec)
339 CPPWAMP_DEPRECATED
ErrorOr(std::error_code ec, std::string)
358 static const std::string empty;
365 value_ = std::move(value);
388 CPPWAMP_HIDDEN
void checkError()
const
396 bool hasError_ =
false;
401 template <
typename T>
403 noexcept(noexcept(x.swap(y)))
410 template <
typename T1,
typename T2>
420 template <
typename T1,
typename T2>
430 template <
typename T1,
typename T2>
438 template <
typename T1,
typename T2>
446 template <
typename T1,
typename T2>
454 template <
typename T1,
typename T2>
462 template <
typename T,
typename E>
470 template <
typename T,
typename E>
478 template <
typename T,
typename E>
486 template <
typename T,
typename E>
499 #endif // CPPWAMP_ERROROR_HPP
ValueType & get()
Definition: erroror.hpp:344
Unexpected(error_type error) noexcept
Constructor taking an error value.
Definition: erroror.hpp:45
const error_type && value() const &&noexcept
Moves the error value.
Definition: erroror.hpp:57
const value_type * operator->() const
Unchecked access of a member of the stored value.
Definition: erroror.hpp:210
ErrorOr & setError(std::error_code ec)
Definition: erroror.hpp:372
value_type value_or(U &&v) const &
Returns the stored value if it exists, or the given fallback value.
Definition: erroror.hpp:308
value_type ValueType
Definition: erroror.hpp:328
Defines macros related to exporting/importing APIs.
const value_type & value() const &
Checked access of the stored value.
Definition: erroror.hpp:275
value_type && value() &&
Checked move of the stored value.
Definition: erroror.hpp:266
ErrorOr & setError(std::error_code ec, std::string)
Definition: erroror.hpp:381
void swap(ErrorOr &rhs) noexcept(std::is_nothrow_swappable< value_type >::value)
Swap contents with another instance.
Definition: erroror.hpp:193
void swap(Unexpected &other) noexcept(std::is_nothrow_swappable< E >::value)
Swaps contents with another UnexpectedError.
Definition: erroror.hpp:60
value_type & emplace(Args &&... args)
Initializes the value in-place using the given value constructor arguments.
Definition: erroror.hpp:159
General purpose runtime exception that wraps a std::error_code.
Definition: error.hpp:52
error_type & error()
Unchecked access of the stored error.
Definition: erroror.hpp:292
ErrorOr & operator=(Unexpected< G > unex)
Error assignment.
Definition: erroror.hpp:184
const value_type & operator*() const &
Unchecked access of the stored value.
Definition: erroror.hpp:234
value_type value_or(U &&v) &&
Returns the moved stored value if it exists, or the given fallback value.
Definition: erroror.hpp:319
std::error_code errorCode() const
Definition: erroror.hpp:350
Unexpected< std::error_code > UnexpectedError
Type alias for Unexpected<std::error_code>.
Definition: erroror.hpp:106
UnexpectedError makeUnexpectedError(TErrorEnum errc)
Convenience function that creates an UnexpectedError from an error code enum.
Definition: erroror.hpp:113
value_type * operator->()
Unchecked access of a member of the stored value.
Definition: erroror.hpp:203
E error_type
Type representing errors.
Definition: erroror.hpp:40
value_type & value() &
Checked access of the stored value.
Definition: erroror.hpp:257
const error_type & error() const
Unchecked access of the stored error.
Definition: erroror.hpp:300
Definition: anyhandler.hpp:36
error_type & value() &noexcept
Accesses the error value.
Definition: erroror.hpp:48
const value_type && operator*() const &&
Unchecked move of the stored value.
Definition: erroror.hpp:242
ErrorOr & setValue(T value)
Definition: erroror.hpp:363
constexpr Unexpected< ValueTypeOf< E > > makeUnexpected(E &&error)
Non-standard factory function needed in C++11 due to lack of CTAD.
Definition: erroror.hpp:98
ErrorOr(std::error_code ec, std::string)
Definition: erroror.hpp:339
bool has_value() const noexcept
Indicates if a value is being contained.
Definition: erroror.hpp:252
ErrorOr(std::error_code ec)
Definition: erroror.hpp:334
Minimalistic implementation of std::unexpected<std::error_code>.
Definition: erroror.hpp:37
error_type && value() &&noexcept
Moves the error value.
Definition: erroror.hpp:51
const std::string & errorInfo() const
Definition: erroror.hpp:356
ErrorOr & operator=(value_type value)
Value assignment.
Definition: erroror.hpp:174
std::function< void(ErrorOr< T >)> AsyncHandler
Type alias for a handler taking an ErrorOr<T> parameter.
Definition: erroror.hpp:495
ErrorOr(Unexpected< G > unex)
Converting constructor taking an Unexpected.
Definition: erroror.hpp:151
Minimalistic implementation of std::expected<T, std::error_code>
Definition: erroror.hpp:128
const value_type && value() const &&
Checked move of the stored value.
Definition: erroror.hpp:284
std::error_code error_type
Type representing errors. */.
Definition: erroror.hpp:132
value_type & operator*() &
Unchecked access of the stored value.
Definition: erroror.hpp:218
ErrorOr(value_type value)
Converting constructor taking a value.
Definition: erroror.hpp:144
Contains general-purpose type traits.
value_type && operator*() &&
Unchecked move of the stored value.
Definition: erroror.hpp:226
T value_type
Type representing result values.
Definition: erroror.hpp:131
const ValueType & get() const
Definition: erroror.hpp:347
const error_type & value() const &noexcept
Accesses the error value.
Definition: erroror.hpp:54
Contains facilities for reporting and describing errors.