Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /* Configure Boost.Outcome with Boost
0002 (C) 2015-2024 Niall Douglas <http://www.nedproductions.biz/> (7 commits)
0003 File Created: August 2015
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_V2_CONFIG_HPP
0032 #define BOOST_OUTCOME_V2_CONFIG_HPP
0033 
0034 #include "detail/version.hpp"
0035 
0036 // Pull in detection of __MINGW64_VERSION_MAJOR
0037 #if defined(__MINGW32__) && !defined(DOXYGEN_IS_IN_THE_HOUSE)
0038 #include <_mingw.h>
0039 #endif
0040 
0041 #include <boost/config.hpp>
0042 
0043 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0044 #error Boost.Outcome needs variadic template support in the compiler
0045 #endif
0046 #if defined(BOOST_NO_CXX14_CONSTEXPR) && _MSC_FULL_VER < 191100000
0047 #error Boost.Outcome needs constexpr (C++ 14) support in the compiler
0048 #endif
0049 #ifdef BOOST_NO_CXX14_VARIABLE_TEMPLATES
0050 #error Boost.Outcome needs variable template support in the compiler
0051 #endif
0052 #if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 6
0053 #error Due to a bug in nested template variables parsing, Boost.Outcome does not work on GCCs earlier than v6.
0054 #endif
0055 
0056 #ifndef BOOST_OUTCOME_SYMBOL_VISIBLE
0057 #define BOOST_OUTCOME_SYMBOL_VISIBLE BOOST_SYMBOL_VISIBLE
0058 #endif
0059 #ifdef __has_cpp_attribute
0060 #define BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr)
0061 #else
0062 #define BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(attr) (0)
0063 #endif
0064 // Weird that Boost.Config doesn't define a BOOST_NO_CXX17_NODISCARD
0065 #ifndef BOOST_OUTCOME_NODISCARD
0066 #if BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(nodiscard)
0067 #define BOOST_OUTCOME_NODISCARD [[nodiscard]]
0068 #elif defined(__clang__)  // deliberately not GCC
0069 #define BOOST_OUTCOME_NODISCARD __attribute__((warn_unused_result))
0070 #elif defined(_MSC_VER)
0071 // _Must_inspect_result_ expands into this
0072 #define BOOST_OUTCOME_NODISCARD                                                                                                                                \
0073   __declspec(                                                                                                                                                  \
0074   "SAL_name"                                                                                                                                                   \
0075   "("                                                                                                                                                          \
0076   "\"_Must_inspect_result_\""                                                                                                                                  \
0077   ","                                                                                                                                                          \
0078   "\"\""                                                                                                                                                       \
0079   ","                                                                                                                                                          \
0080   "\"2\""                                                                                                                                                      \
0081   ")") __declspec("SAL_begin") __declspec("SAL_post") __declspec("SAL_mustInspect") __declspec("SAL_post") __declspec("SAL_checkReturn") __declspec("SAL_end")
0082 #endif
0083 #endif
0084 #ifndef BOOST_OUTCOME_NODISCARD
0085 #define BOOST_OUTCOME_NODISCARD
0086 #endif
0087 #ifndef BOOST_OUTCOME_THREAD_LOCAL
0088 #ifndef BOOST_NO_CXX11_THREAD_LOCAL
0089 #define BOOST_OUTCOME_THREAD_LOCAL thread_local
0090 #else
0091 #if defined(_MSC_VER)
0092 #define BOOST_OUTCOME_THREAD_LOCAL __declspec(thread)
0093 #elif defined(__GNUC__)
0094 #define BOOST_OUTCOME_THREAD_LOCAL __thread
0095 #else
0096 #error Unknown compiler, cannot set BOOST_OUTCOME_THREAD_LOCAL
0097 #endif
0098 #endif
0099 #endif
0100 // Can't use the QuickCppLib preprocessor metaprogrammed Concepts TS support, so ...
0101 #ifndef BOOST_OUTCOME_TEMPLATE
0102 #define BOOST_OUTCOME_TEMPLATE(...) template <__VA_ARGS__
0103 #endif
0104 #ifndef BOOST_OUTCOME_TREQUIRES
0105 #define BOOST_OUTCOME_TREQUIRES(...) , __VA_ARGS__ >
0106 #endif
0107 #ifndef BOOST_OUTCOME_TEXPR
0108 #define BOOST_OUTCOME_TEXPR(...) typename = decltype(__VA_ARGS__)
0109 #endif
0110 #ifndef BOOST_OUTCOME_TPRED
0111 #define BOOST_OUTCOME_TPRED(...) typename = std::enable_if_t<__VA_ARGS__>
0112 #endif
0113 #ifndef BOOST_OUTCOME_REQUIRES
0114 #if defined(__cpp_concepts) && (!defined(_MSC_VER) || _MSC_FULL_VER >= 192400000)  // VS 2019 16.3 is broken here
0115 #define BOOST_OUTCOME_REQUIRES(...) requires(__VA_ARGS__)
0116 #else
0117 #define BOOST_OUTCOME_REQUIRES(...)
0118 #endif
0119 #endif
0120 
0121 #ifndef BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR
0122 #define BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR 220  // the v2.2 Outcome release
0123 #endif
0124 
0125 namespace boost
0126 {
0127 #define BOOST_OUTCOME_V2
0128   //! The Boost.Outcome namespace
0129   namespace outcome_v2
0130   {
0131   }
0132 }
0133 /*! The namespace of this Boost.Outcome v2.
0134  */
0135 #define BOOST_OUTCOME_V2_NAMESPACE boost::outcome_v2
0136 /*! Expands into the appropriate namespace markup to enter the Boost.Outcome v2 namespace.
0137  */
0138 #define BOOST_OUTCOME_V2_NAMESPACE_BEGIN                                                                                                                       \
0139   namespace boost                                                                                                                                              \
0140   {                                                                                                                                                            \
0141     namespace outcome_v2                                                                                                                                       \
0142     {
0143 /*! Expands into the appropriate namespace markup to enter the C++ module
0144 exported Boost.Outcome v2 namespace.
0145 */
0146 #define BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN                                                                                                                \
0147   namespace boost                                                                                                                                              \
0148   {                                                                                                                                                            \
0149     namespace outcome_v2                                                                                                                                       \
0150     {
0151 /*! \brief Expands into the appropriate namespace markup to exit the Boost.Outcome v2 namespace.
0152 \ingroup config
0153 */
0154 #define BOOST_OUTCOME_V2_NAMESPACE_END                                                                                                                         \
0155   }                                                                                                                                                            \
0156   }
0157 
0158 #include <cstdint>  // for uint32_t etc
0159 #include <initializer_list>
0160 #include <iosfwd>  // for future serialisation
0161 #include <new>     // for placement in moves etc
0162 #include <type_traits>
0163 
0164 #ifndef BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE
0165 #if defined(_MSC_VER) && _HAS_CXX17
0166 #define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 1  // MSVC always has std::in_place_type
0167 #elif __cplusplus >= 201700
0168 // libstdc++ before GCC 6 doesn't have it, despite claiming C++ 17 support
0169 #ifdef __has_include
0170 #if !__has_include(<variant>)
0171 #define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 0  // must have it if <variant> is present
0172 #endif
0173 #endif
0174 
0175 #ifndef BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE
0176 #define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 1
0177 #endif
0178 #else
0179 #define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 0
0180 #endif
0181 #endif
0182 
0183 #if BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE
0184 #include <utility>  // for in_place_type_t
0185 
0186 BOOST_OUTCOME_V2_NAMESPACE_BEGIN
0187 template <class T> using in_place_type_t = std::in_place_type_t<T>;
0188 using std::in_place_type;
0189 BOOST_OUTCOME_V2_NAMESPACE_END
0190 #else
0191 BOOST_OUTCOME_V2_NAMESPACE_BEGIN
0192 //! Aliases `std::in_place_type_t<T>` if on C++ 17 or later, else defined locally.
0193 template <class T> struct in_place_type_t
0194 {
0195   explicit in_place_type_t() = default;
0196 };
0197 //! Aliases `std::in_place_type<T>` if on C++ 17 or later, else defined locally.
0198 template <class T> constexpr in_place_type_t<T> in_place_type{};
0199 BOOST_OUTCOME_V2_NAMESPACE_END
0200 #endif
0201 
0202 #if defined(BOOST_OUTCOME_USE_STD_ADDRESSOF) && !BOOST_OUTCOME_USE_STD_ADDRESSOF
0203 #define BOOST_OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__)
0204 #else
0205 #include <memory>  // for std::addressof
0206 #define BOOST_OUTCOME_ADDRESS_OF(...) std::addressof(__VA_ARGS__)
0207 #endif
0208 
0209 #ifndef BOOST_OUTCOME_ASSERT
0210 #include <boost/assert.hpp>
0211 #define BOOST_OUTCOME_ASSERT(...) BOOST_ASSERT(__VA_ARGS__)
0212 #endif
0213 
0214 #ifndef BOOST_OUTCOME_TRIVIAL_ABI
0215 #if defined(STANDARDESE_IS_IN_THE_HOUSE) || __clang_major__ >= 7
0216 //! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden.
0217 #define BOOST_OUTCOME_TRIVIAL_ABI [[clang::trivial_abi]]
0218 #else
0219 #define BOOST_OUTCOME_TRIVIAL_ABI
0220 #endif
0221 #endif
0222 
0223 BOOST_OUTCOME_V2_NAMESPACE_BEGIN
0224 namespace detail
0225 {
0226   // Test if type is an in_place_type_t
0227   template <class T> struct is_in_place_type_t
0228   {
0229     static constexpr bool value = false;
0230   };
0231   template <class U> struct is_in_place_type_t<in_place_type_t<U>>
0232   {
0233     static constexpr bool value = true;
0234   };
0235 
0236   // Replace void with constructible void_type
0237   struct empty_type
0238   {
0239   };
0240   struct void_type
0241   {
0242     // We always compare true to another instance of me
0243     constexpr bool operator==(void_type /*unused*/) const noexcept { return true; }
0244     constexpr bool operator!=(void_type /*unused*/) const noexcept { return false; }
0245   };
0246   template <class T> using devoid = std::conditional_t<std::is_void<T>::value, void_type, T>;
0247 
0248   template <class Output, class Input> using rebind_type5 = Output;
0249   template <class Output, class Input>
0250   using rebind_type4 = std::conditional_t<                                   //
0251   std::is_volatile<Input>::value,                                            //
0252   std::add_volatile_t<rebind_type5<Output, std::remove_volatile_t<Input>>>,  //
0253   rebind_type5<Output, Input>>;
0254   template <class Output, class Input>
0255   using rebind_type3 = std::conditional_t<                             //
0256   std::is_const<Input>::value,                                         //
0257   std::add_const_t<rebind_type4<Output, std::remove_const_t<Input>>>,  //
0258   rebind_type4<Output, Input>>;
0259   template <class Output, class Input>
0260   using rebind_type2 = std::conditional_t<                                            //
0261   std::is_lvalue_reference<Input>::value,                                             //
0262   std::add_lvalue_reference_t<rebind_type3<Output, std::remove_reference_t<Input>>>,  //
0263   rebind_type3<Output, Input>>;
0264   template <class Output, class Input>
0265   using rebind_type = std::conditional_t<                                             //
0266   std::is_rvalue_reference<Input>::value,                                             //
0267   std::add_rvalue_reference_t<rebind_type2<Output, std::remove_reference_t<Input>>>,  //
0268   rebind_type2<Output, Input>>;
0269 
0270   // static_assert(std::is_same_v<rebind_type<int, volatile const double &&>, volatile const int &&>, "");
0271 
0272 
0273   /* True if type is the same or constructible. Works around a bug where clang + libstdc++
0274   pukes on std::is_constructible<filesystem::path, void> (this bug is fixed upstream).
0275   */
0276   template <class T, class U> struct _is_explicitly_constructible
0277   {
0278     static constexpr bool value = std::is_constructible<T, U>::value;
0279   };
0280   template <class T> struct _is_explicitly_constructible<T, void>
0281   {
0282     static constexpr bool value = false;
0283   };
0284   template <> struct _is_explicitly_constructible<void, void>
0285   {
0286     static constexpr bool value = false;
0287   };
0288   template <class T, class U> static constexpr bool is_explicitly_constructible = _is_explicitly_constructible<T, U>::value;
0289 
0290   template <class T, class U> struct _is_implicitly_constructible
0291   {
0292     static constexpr bool value = std::is_convertible<U, T>::value;
0293   };
0294   template <class T> struct _is_implicitly_constructible<T, void>
0295   {
0296     static constexpr bool value = false;
0297   };
0298   template <> struct _is_implicitly_constructible<void, void>
0299   {
0300     static constexpr bool value = false;
0301   };
0302   template <class T, class U> static constexpr bool is_implicitly_constructible = _is_implicitly_constructible<T, U>::value;
0303 
0304   template <class T, class... Args> struct _is_nothrow_constructible
0305   {
0306     static constexpr bool value = std::is_nothrow_constructible<T, Args...>::value;
0307   };
0308   template <class T> struct _is_nothrow_constructible<T, void>
0309   {
0310     static constexpr bool value = false;
0311   };
0312   template <> struct _is_nothrow_constructible<void, void>
0313   {
0314     static constexpr bool value = false;
0315   };
0316   template <class T, class... Args> static constexpr bool is_nothrow_constructible = _is_nothrow_constructible<T, Args...>::value;
0317 
0318   template <class T, class... Args> struct _is_constructible
0319   {
0320     static constexpr bool value = std::is_constructible<T, Args...>::value;
0321   };
0322   template <class T> struct _is_constructible<T, void>
0323   {
0324     static constexpr bool value = false;
0325   };
0326   template <> struct _is_constructible<void, void>
0327   {
0328     static constexpr bool value = false;
0329   };
0330   template <class T, class... Args> static constexpr bool is_constructible = _is_constructible<T, Args...>::value;
0331 
0332 #ifndef BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE
0333 #if defined(_MSC_VER) && _HAS_CXX17
0334 #define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 1  // MSVC always has std::is_nothrow_swappable
0335 #elif __cplusplus >= 201700
0336 // libstdc++ before GCC 6 doesn't have it, despite claiming C++ 17 support
0337 #ifdef __has_include
0338 #if !__has_include(<variant>)
0339 #define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 0  // must have it if <variant> is present
0340 #endif
0341 #endif
0342 
0343 #ifndef BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE
0344 #define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 1
0345 #endif
0346 #else
0347 #define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 0
0348 #endif
0349 #endif
0350 
0351 // True if type is nothrow swappable
0352 #if !defined(STANDARDESE_IS_IN_THE_HOUSE) && BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE
0353   template <class T> using is_nothrow_swappable = std::is_nothrow_swappable<T>;
0354 #else
0355   template <class T> struct is_nothrow_swappable
0356   {
0357     static constexpr bool value = std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value;
0358   };
0359 #endif
0360 }  // namespace detail
0361 BOOST_OUTCOME_V2_NAMESPACE_END
0362 
0363 #ifndef BOOST_OUTCOME_THROW_EXCEPTION
0364 #include <boost/throw_exception.hpp>
0365 #define BOOST_OUTCOME_THROW_EXCEPTION(expr) BOOST_THROW_EXCEPTION(expr)
0366 #endif
0367 
0368 #ifndef BOOST_OUTCOME_AUTO_TEST_CASE
0369 #define BOOST_OUTCOME_AUTO_TEST_CASE(a, b) BOOST_AUTO_TEST_CASE(a)
0370 #endif
0371 
0372 #endif