Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:59:13

0001 /* A very simple result type
0002 (C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (10 commits)
0003 File Created: June 2017
0004 
0005 
0006 Boost Software License - Version 1.0 - August 17th, 2003
0007 
0008 Permission is hereby granted, free of charge, to any person or organization
0009 obtaining a copy of the software and accompanying documentation covered by
0010 this license (the "Software") to use, reproduce, display, distribute,
0011 execute, and transmit the Software, and to prepare derivative works of the
0012 Software, and to permit third-parties to whom the Software is furnished to
0013 do so, all subject to the following:
0014 
0015 The copyright notices in the Software and this entire statement, including
0016 the above license grant, this restriction and the following disclaimer,
0017 must be included in all copies of the Software, in whole or in part, and
0018 all derivative works of the Software, unless such copies or derivative
0019 works are solely in the form of machine-executable object code generated by
0020 a source language processor.
0021 
0022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0024 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
0025 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
0026 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
0027 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0028 DEALINGS IN THE SOFTWARE.
0029 */
0030 
0031 #ifndef BOOST_OUTCOME_BOOST_RESULT_HPP
0032 #define BOOST_OUTCOME_BOOST_RESULT_HPP
0033 
0034 #include "config.hpp"
0035 
0036 #include "boost/system/system_error.hpp"
0037 #include "boost/exception_ptr.hpp"
0038 #include "boost/version.hpp"
0039 
0040 BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN
0041 
0042 /*! AWAITING HUGO JSON CONVERSION TOOL
0043 SIGNATURE NOT RECOGNISED
0044 */
0045 namespace policy
0046 {
0047   namespace detail
0048   {
0049     /* Pass through `make_error_code` function for `boost::system::error_code`.
0050      */
0051     inline boost::system::error_code make_error_code(boost::system::error_code v) { return v; }
0052 
0053     /* Pass through `make_exception_ptr` function for `boost::exception_ptr`.
0054     */
0055     inline boost::exception_ptr make_exception_ptr(boost::exception_ptr v) { return v; }
0056   }  // namespace detail
0057 }  // namespace policy
0058 BOOST_OUTCOME_V2_NAMESPACE_END
0059 
0060 #include "std_result.hpp"
0061 
0062 
0063 // ADL injection of outcome_throw_as_system_error_with_payload
0064 namespace boost
0065 {
0066   namespace system
0067   {
0068     inline void outcome_throw_as_system_error_with_payload(const error_code &error) { BOOST_OUTCOME_THROW_EXCEPTION(system_error(error)); }
0069     namespace errc
0070     {
0071       BOOST_OUTCOME_TEMPLATE(class Error)
0072       BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(is_error_code_enum<std::decay_t<Error>>::value || is_error_condition_enum<std::decay_t<Error>>::value))
0073       inline void outcome_throw_as_system_error_with_payload(Error &&error) { BOOST_OUTCOME_THROW_EXCEPTION(system_error(make_error_code(error))); }
0074     }  // namespace errc
0075   }    // namespace system
0076 }  // namespace boost
0077 
0078 BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN
0079 
0080 namespace detail
0081 {
0082   // Customise _set_error_is_errno
0083   template <class State> constexpr inline void _set_error_is_errno(State &state, const boost::system::error_code &error)
0084   {
0085     if(error.category() == boost::system::generic_category()
0086 #ifndef _WIN32
0087        || error.category() == boost::system::system_category()
0088 #endif
0089     )
0090     {
0091       state._status.set_have_error_is_errno(true);
0092     }
0093   }
0094   template <class State> constexpr inline void _set_error_is_errno(State &state, const boost::system::error_condition &error)
0095   {
0096     if(error.category() == boost::system::generic_category()
0097 #ifndef _WIN32
0098        || error.category() == boost::system::system_category()
0099 #endif
0100     )
0101     {
0102       state._status.set_have_error_is_errno(true);
0103     }
0104   }
0105   template <class State> constexpr inline void _set_error_is_errno(State &state, const boost::system::errc::errc_t & /*unused*/)
0106   {
0107     state._status.set_have_error_is_errno(true);
0108   }
0109 
0110 }  // namespace detail
0111 
0112 /*! AWAITING HUGO JSON CONVERSION TOOL
0113 SIGNATURE NOT RECOGNISED
0114 */
0115 namespace trait
0116 {
0117   namespace detail
0118   {
0119     // Shortcut these for lower build impact
0120     template <> struct _is_error_code_available<boost::system::error_code>
0121     {
0122       static constexpr bool value = true;
0123       using type = boost::system::error_code;
0124     };
0125     template <> struct _is_exception_ptr_available<boost::exception_ptr>
0126     {
0127       static constexpr bool value = true;
0128       using type = boost::exception_ptr;
0129     };
0130   }  // namespace detail
0131 
0132   // boost::system::error_code is an error type
0133   template <> struct is_error_type<boost::system::error_code>
0134   {
0135     static constexpr bool value = true;
0136   };
0137   // boost::system::error_code::errc_t is an error type
0138   template <> struct is_error_type<boost::system::errc::errc_t>
0139   {
0140     static constexpr bool value = true;
0141   };
0142   // boost::exception_ptr is an error types
0143   template <> struct is_error_type<boost::exception_ptr>
0144   {
0145     static constexpr bool value = true;
0146   };
0147   // For boost::system::error_code, boost::system::is_error_condition_enum<> is the trait we want.
0148   template <class Enum> struct is_error_type_enum<boost::system::error_code, Enum>
0149   {
0150     static constexpr bool value = boost::system::is_error_condition_enum<Enum>::value;
0151   };
0152 
0153 }  // namespace trait
0154 
0155 
0156 /*! AWAITING HUGO JSON CONVERSION TOOL
0157 SIGNATURE NOT RECOGNISED
0158 */
0159 template <class R, class S = boost::system::error_code, class NoValuePolicy = policy::default_policy<R, S, void>>  //
0160 using boost_result = basic_result<R, S, NoValuePolicy>;
0161 
0162 /*! AWAITING HUGO JSON CONVERSION TOOL
0163 type alias template <class R, class S = boost::system::error_code> boost_unchecked. Potential doc page: `boost_unchecked<T, E = boost::system::error_code>`
0164 */
0165 template <class R, class S = boost::system::error_code> using boost_unchecked = boost_result<R, S, policy::all_narrow>;
0166 
0167 /*! AWAITING HUGO JSON CONVERSION TOOL
0168 type alias template <class R, class S = boost::system::error_code> boost_checked. Potential doc page: `boost_checked<T, E = boost::system::error_code>`
0169 */
0170 template <class R, class S = boost::system::error_code> using boost_checked = boost_result<R, S, policy::throw_bad_result_access<S, void>>;
0171 
0172 BOOST_OUTCOME_V2_NAMESPACE_END
0173 
0174 #endif