Warning, file /include/boost/outcome/experimental/status-code/status_error.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_ERROR_HPP
0026 #define BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_ERROR_HPP
0027
0028 #include "status_code.hpp"
0029
0030 #include <exception> // for std::exception
0031
0032 BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN
0033
0034
0035
0036 template <class DomainType> class status_error;
0037
0038
0039
0040 template <> class status_error<void> : public std::exception
0041 {
0042 protected:
0043
0044 status_error() = default;
0045
0046 status_error(const status_error &) = default;
0047
0048 status_error(status_error &&) = default;
0049
0050 status_error &operator=(const status_error &) = default;
0051
0052 status_error &operator=(status_error &&) = default;
0053
0054 ~status_error() override = default;
0055
0056 virtual const status_code<void> &_do_code() const noexcept = 0;
0057
0058 public:
0059
0060 using domain_type = void;
0061
0062 using status_code_type = status_code<void>;
0063
0064 public:
0065
0066 const status_code<void> &code() const noexcept { return _do_code(); }
0067 };
0068
0069
0070
0071 template <class DomainType> class status_error : public status_error<void>
0072 {
0073 status_code<DomainType> _code;
0074 typename DomainType::string_ref _msgref;
0075
0076 virtual const status_code<void> &_do_code() const noexcept override final { return _code; }
0077
0078 public:
0079
0080 using domain_type = DomainType;
0081
0082 using status_code_type = status_code<DomainType>;
0083
0084
0085 explicit status_error(status_code<DomainType> code)
0086 : _code(static_cast<status_code<DomainType> &&>(code))
0087 , _msgref(_code.message())
0088 {
0089 }
0090
0091
0092 virtual const char *what() const noexcept override { return _msgref.c_str(); }
0093
0094
0095 const status_code_type &code() const & { return _code; }
0096
0097 status_code_type &code() & { return _code; }
0098
0099 const status_code_type &&code() const && { return _code; }
0100
0101 status_code_type &&code() && { return _code; }
0102 };
0103
0104
0105
0106 template <class ErasedType> class status_error<detail::erased<ErasedType>> : public status_error<void>
0107 {
0108 status_code<detail::erased<ErasedType>> _code;
0109 typename status_code_domain::string_ref _msgref;
0110
0111 virtual const status_code<detail::erased<ErasedType>> &_do_code() const noexcept override final { return _code; }
0112
0113 public:
0114
0115 using domain_type = void;
0116
0117 using status_code_type = status_code<detail::erased<ErasedType>>;
0118
0119
0120 explicit status_error(status_code<detail::erased<ErasedType>> code)
0121 : _code(static_cast<status_code<detail::erased<ErasedType>> &&>(code))
0122 , _msgref(_code.message())
0123 {
0124 }
0125
0126
0127 virtual const char *what() const noexcept override { return _msgref.c_str(); }
0128
0129
0130 const status_code_type &code() const & { return _code; }
0131
0132 status_code_type &code() & { return _code; }
0133
0134 const status_code_type &&code() const && { return _code; }
0135
0136 status_code_type &&code() && { return _code; }
0137 };
0138
0139 BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END
0140
0141 #endif