File indexing completed on 2025-12-16 09:59:14
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_V2_CONFIG_HPP
0032 #define BOOST_OUTCOME_V2_CONFIG_HPP
0033
0034 #include "detail/version.hpp"
0035
0036
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
0065 #ifndef BOOST_OUTCOME_NODISCARD
0066 #if BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(nodiscard)
0067 #define BOOST_OUTCOME_NODISCARD [[nodiscard]]
0068 #elif defined(__clang__)
0069 #define BOOST_OUTCOME_NODISCARD __attribute__((warn_unused_result))
0070 #elif defined(_MSC_VER)
0071
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
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)
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
0123 #endif
0124
0125 namespace boost
0126 {
0127 #define BOOST_OUTCOME_V2
0128
0129 namespace outcome_v2
0130 {
0131 }
0132 }
0133
0134
0135 #define BOOST_OUTCOME_V2_NAMESPACE boost::outcome_v2
0136
0137
0138 #define BOOST_OUTCOME_V2_NAMESPACE_BEGIN \
0139 namespace boost \
0140 { \
0141 namespace outcome_v2 \
0142 {
0143
0144
0145
0146 #define BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN \
0147 namespace boost \
0148 { \
0149 namespace outcome_v2 \
0150 {
0151
0152
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
0167 #elif __cplusplus >= 201700
0168
0169 #ifdef __has_include
0170 #if !__has_include(<variant>)
0171 #define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 0
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
0193 template <class T> struct in_place_type_t
0194 {
0195 explicit in_place_type_t() = default;
0196 };
0197
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
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
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
0237 struct empty_type
0238 {
0239 };
0240 struct void_type
0241 {
0242
0243 constexpr bool operator==(void_type ) const noexcept { return true; }
0244 constexpr bool operator!=(void_type ) 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
0271
0272
0273
0274
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
0335 #elif __cplusplus >= 201700
0336
0337 #ifdef __has_include
0338 #if !__has_include(<variant>)
0339 #define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 0
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
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 }
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