File indexing completed on 2025-01-30 09:49:51
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_THROW_BAD_RESULT_ACCESS_HPP
0032 #define BOOST_OUTCOME_POLICY_THROW_BAD_RESULT_ACCESS_HPP
0033
0034 #include "../bad_access.hpp"
0035 #include "base.hpp"
0036
0037 BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN
0038
0039 namespace policy
0040 {
0041
0042
0043
0044 template <class EC, class EP> struct throw_bad_result_access : base
0045 {
0046 template <class Impl> static constexpr void wide_value_check(Impl &&self)
0047 {
0048 if(!base::_has_value(std::forward<Impl>(self)))
0049 {
0050 BOOST_OUTCOME_THROW_EXCEPTION(bad_outcome_access("no value"));
0051 }
0052 }
0053 template <class Impl> static constexpr void wide_error_check(Impl &&self)
0054 {
0055 if(!base::_has_error(std::forward<Impl>(self)))
0056 {
0057 BOOST_OUTCOME_THROW_EXCEPTION(bad_outcome_access("no error"));
0058 }
0059 }
0060 template <class Impl> static constexpr void wide_exception_check(Impl &&self)
0061 {
0062 if(!base::_has_exception(std::forward<Impl>(self)))
0063 {
0064 BOOST_OUTCOME_THROW_EXCEPTION(bad_outcome_access("no exception"));
0065 }
0066 }
0067 };
0068 template <class EC> struct throw_bad_result_access<EC, void> : base
0069 {
0070 template <class Impl> static constexpr void wide_value_check(Impl &&self)
0071 {
0072 if(!base::_has_value(std::forward<Impl>(self)))
0073 {
0074 if(base::_has_error(std::forward<Impl>(self)))
0075 {
0076 BOOST_OUTCOME_THROW_EXCEPTION(bad_result_access_with<EC>(base::_error(std::forward<Impl>(self))));
0077 }
0078 BOOST_OUTCOME_THROW_EXCEPTION(bad_result_access("no value"));
0079 }
0080 }
0081 template <class Impl> static constexpr void wide_error_check(Impl &&self)
0082 {
0083 if(!base::_has_error(std::forward<Impl>(self)))
0084 {
0085 BOOST_OUTCOME_THROW_EXCEPTION(bad_result_access("no error"));
0086 }
0087 }
0088 };
0089 }
0090
0091 BOOST_OUTCOME_V2_NAMESPACE_END
0092
0093 #endif