Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /* Policies for result and outcome
0002 (C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (6 commits) and Andrzej KrzemieĊ„ski <akrzemi1@gmail.com> (1 commit)
0003 File Created: Oct 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_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 /*! AWAITING HUGO JSON CONVERSION TOOL
0040 SIGNATURE NOT RECOGNISED
0041 */
0042 namespace hooks
0043 {
0044   /*! AWAITING HUGO JSON CONVERSION TOOL
0045 SIGNATURE NOT RECOGNISED
0046 */
0047   template <class T, class U> constexpr inline void hook_result_construction(T * /*unused*/, U && /*unused*/) noexcept {}
0048   /*! AWAITING HUGO JSON CONVERSION TOOL
0049 SIGNATURE NOT RECOGNISED
0050 */
0051   template <class T, class U> constexpr inline void hook_result_copy_construction(T * /*unused*/, U && /*unused*/) noexcept {}
0052   /*! AWAITING HUGO JSON CONVERSION TOOL
0053 SIGNATURE NOT RECOGNISED
0054 */
0055   template <class T, class U> constexpr inline void hook_result_move_construction(T * /*unused*/, U && /*unused*/) noexcept {}
0056   /*! AWAITING HUGO JSON CONVERSION TOOL
0057 SIGNATURE NOT RECOGNISED
0058 */
0059   template <class T, class U, class... Args>
0060   constexpr inline void hook_result_in_place_construction(T * /*unused*/, in_place_type_t<U> /*unused*/, Args &&... /*unused*/) noexcept
0061   {
0062   }
0063   /*! AWAITING HUGO JSON CONVERSION TOOL
0064 SIGNATURE NOT RECOGNISED
0065 */
0066   template <class T, class... U> constexpr inline void hook_outcome_construction(T * /*unused*/, U &&... /*unused*/) noexcept {}
0067   /*! AWAITING HUGO JSON CONVERSION TOOL
0068 SIGNATURE NOT RECOGNISED
0069 */
0070   template <class T, class U> constexpr inline void hook_outcome_copy_construction(T * /*unused*/, U && /*unused*/) noexcept {}
0071   /*! AWAITING HUGO JSON CONVERSION TOOL
0072 SIGNATURE NOT RECOGNISED
0073 */
0074   template <class T, class U> constexpr inline void hook_outcome_move_construction(T * /*unused*/, U && /*unused*/) noexcept {}
0075   /*! AWAITING HUGO JSON CONVERSION TOOL
0076 SIGNATURE NOT RECOGNISED
0077 */
0078   template <class T, class U, class... Args>
0079   constexpr inline void hook_outcome_in_place_construction(T * /*unused*/, in_place_type_t<U> /*unused*/, Args &&... /*unused*/) noexcept
0080   {
0081   }
0082 }  // namespace hooks
0083 #endif
0084 
0085 namespace policy
0086 {
0087   namespace detail
0088   {
0089     using BOOST_OUTCOME_V2_NAMESPACE::detail::make_ub;
0090   }
0091   /*! AWAITING HUGO JSON CONVERSION TOOL
0092 SIGNATURE NOT RECOGNISED
0093 */
0094   struct base
0095   {
0096     template <class... Args> static constexpr void _silence_unused(Args &&... /*unused*/) 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 }  // namespace policy
0224 
0225 BOOST_OUTCOME_V2_NAMESPACE_END
0226 
0227 #endif