File indexing completed on 2025-12-16 09:59:12
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
0026
0027
0028
0029
0030
0031 #ifndef BOOST_OUTCOME_POLICY_BASE_HPP
0032 #define BOOST_OUTCOME_POLICY_BASE_HPP
0033
0034 #include "../detail/value_storage.hpp"
0035
0036 BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN
0037
0038 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0039
0040
0041
0042 namespace hooks
0043 {
0044
0045
0046
0047 template <class T, class U> constexpr inline void hook_result_construction(T * , U && ) noexcept {}
0048
0049
0050
0051 template <class T, class U> constexpr inline void hook_result_copy_construction(T * , U && ) noexcept {}
0052
0053
0054
0055 template <class T, class U> constexpr inline void hook_result_move_construction(T * , U && ) noexcept {}
0056
0057
0058
0059 template <class T, class U, class... Args>
0060 constexpr inline void hook_result_in_place_construction(T * , in_place_type_t<U> , Args &&... ) noexcept
0061 {
0062 }
0063
0064
0065
0066 template <class T, class... U> constexpr inline void hook_outcome_construction(T * , U &&... ) noexcept {}
0067
0068
0069
0070 template <class T, class U> constexpr inline void hook_outcome_copy_construction(T * , U && ) noexcept {}
0071
0072
0073
0074 template <class T, class U> constexpr inline void hook_outcome_move_construction(T * , U && ) noexcept {}
0075
0076
0077
0078 template <class T, class U, class... Args>
0079 constexpr inline void hook_outcome_in_place_construction(T * , in_place_type_t<U> , Args &&... ) noexcept
0080 {
0081 }
0082 }
0083 #endif
0084
0085 namespace policy
0086 {
0087 namespace detail
0088 {
0089 using BOOST_OUTCOME_V2_NAMESPACE::detail::make_ub;
0090 }
0091
0092
0093
0094 struct base
0095 {
0096 template <class... Args> static constexpr void _silence_unused(Args &&... ) noexcept {}
0097 protected:
0098 template <class Impl> static constexpr void _make_ub(Impl &&self) noexcept { return detail::make_ub(static_cast<Impl &&>(self)); }
0099 template <class Impl> static constexpr bool _has_value(Impl &&self) noexcept { return self._state._status.have_value(); }
0100 template <class Impl> static constexpr bool _has_error(Impl &&self) noexcept { return self._state._status.have_error(); }
0101 template <class Impl> static constexpr bool _has_exception(Impl &&self) noexcept { return self._state._status.have_exception(); }
0102 template <class Impl> static constexpr bool _has_error_is_errno(Impl &&self) noexcept { return self._state._status.have_error_is_errno(); }
0103
0104 template <class Impl> static constexpr void _set_has_value(Impl &&self, bool v) noexcept { self._state._status.set_have_value(v); }
0105 template <class Impl> static constexpr void _set_has_error(Impl &&self, bool v) noexcept { self._state._status.set_have_error(v); }
0106 template <class Impl> static constexpr void _set_has_exception(Impl &&self, bool v) noexcept { self._state._status.set_have_exception(v); }
0107 template <class Impl> static constexpr void _set_has_error_is_errno(Impl &&self, bool v) noexcept { self._state._status.set_have_error_is_errno(v); }
0108
0109 template <class Impl> static constexpr auto &&_value(Impl &&self) noexcept { return static_cast<Impl &&>(self)._state._value; }
0110 template <class Impl> static constexpr auto &&_error(Impl &&self) noexcept { return static_cast<Impl &&>(self)._state._error; }
0111
0112 public:
0113 template <class R, class S, class P, class NoValuePolicy, class Impl> static inline constexpr auto &&_exception(Impl &&self) noexcept;
0114
0115 template <class T, class U> static constexpr inline void on_result_construction(T *inst, U &&v) noexcept
0116 {
0117 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0118 using namespace hooks;
0119 hook_result_construction(inst, static_cast<U &&>(v));
0120 #else
0121 (void) inst;
0122 (void) v;
0123 #endif
0124 }
0125 template <class T, class U> static constexpr inline void on_result_copy_construction(T *inst, U &&v) noexcept
0126 {
0127 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0128 using namespace hooks;
0129 hook_result_copy_construction(inst, static_cast<U &&>(v));
0130 #else
0131 (void) inst;
0132 (void) v;
0133 #endif
0134 }
0135 template <class T, class U> static constexpr inline void on_result_move_construction(T *inst, U &&v) noexcept
0136 {
0137 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0138 using namespace hooks;
0139 hook_result_move_construction(inst, static_cast<U &&>(v));
0140 #else
0141 (void) inst;
0142 (void) v;
0143 #endif
0144 }
0145 template <class T, class U, class... Args>
0146 static constexpr inline void on_result_in_place_construction(T *inst, in_place_type_t<U> _, Args &&... args) noexcept
0147 {
0148 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0149 using namespace hooks;
0150 hook_result_in_place_construction(inst, _, static_cast<Args &&>(args)...);
0151 #else
0152 (void) inst;
0153 (void) _;
0154 _silence_unused(static_cast<Args &&>(args)...);
0155 #endif
0156 }
0157
0158 template <class T, class... U> static constexpr inline void on_outcome_construction(T *inst, U &&... args) noexcept
0159 {
0160 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0161 using namespace hooks;
0162 hook_outcome_construction(inst, static_cast<U &&>(args)...);
0163 #else
0164 (void) inst;
0165 _silence_unused(static_cast<U &&>(args)...);
0166 #endif
0167 }
0168 template <class T, class U> static constexpr inline void on_outcome_copy_construction(T *inst, U &&v) noexcept
0169 {
0170 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0171 using namespace hooks;
0172 hook_outcome_copy_construction(inst, static_cast<U &&>(v));
0173 #else
0174 (void) inst;
0175 (void) v;
0176 #endif
0177 }
0178 template <class T, class U> static constexpr inline void on_outcome_move_construction(T *inst, U &&v) noexcept
0179 {
0180 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0181 using namespace hooks;
0182 hook_outcome_move_construction(inst, static_cast<U &&>(v));
0183 #else
0184 (void) inst;
0185 (void) v;
0186 #endif
0187 }
0188 template <class T, class U, class... Args>
0189 static constexpr inline void on_outcome_in_place_construction(T *inst, in_place_type_t<U> _, Args &&... args) noexcept
0190 {
0191 #if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220
0192 using namespace hooks;
0193 hook_outcome_in_place_construction(inst, _, static_cast<Args &&>(args)...);
0194 #else
0195 (void) inst;
0196 (void) _;
0197 _silence_unused(static_cast<Args &&>(args)...);
0198 #endif
0199 }
0200
0201 template <class Impl> static constexpr void narrow_value_check(Impl &&self) noexcept
0202 {
0203 if(!_has_value(self))
0204 {
0205 _make_ub(self);
0206 }
0207 }
0208 template <class Impl> static constexpr void narrow_error_check(Impl &&self) noexcept
0209 {
0210 if(!_has_error(self))
0211 {
0212 _make_ub(self);
0213 }
0214 }
0215 template <class Impl> static constexpr void narrow_exception_check(Impl &&self) noexcept
0216 {
0217 if(!_has_exception(self))
0218 {
0219 _make_ub(self);
0220 }
0221 }
0222 };
0223 }
0224
0225 BOOST_OUTCOME_V2_NAMESPACE_END
0226
0227 #endif