diff --git a/.boostify b/.boostify index 5afca4e89dc..8826c0bc64d 100644 --- a/.boostify +++ b/.boostify @@ -1,6 +1,6 @@ # Files to copy over include_files = [ - (r'include/outcome/experimental/status-code/include/(.*)', r'include/boost/outcome/experimental/status-code/\1'), + (r'include/outcome/experimental/status-code/include/(.*)', r'include/boost/outcome/experimental/\1'), (r'include/(.*)', r'include/boost/\1'), r'^doc/src/.*$', r'^test/.*$', @@ -47,7 +47,7 @@ core_macros = { r'^SYSTEM_ERROR2_': r'BOOST_OUTCOME_SYSTEM_ERROR2_', r'([^_])SYSTEM_ERROR2_': r'\1BOOST_OUTCOME_SYSTEM_ERROR2_', r']+)': r'` which is not desirable. +This has now been remedied to remove the double `status-code`, which will obviously break +any Boost.Outcome code which relies on the double `status-code`. Standalone Outcome is unaffected. + +### Bug fixes: + --- ## v2.2.8 13th December 2023 (Boost 1.84) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.8) diff --git a/doc/src/content/reference/policies/base/ub.md b/doc/src/content/reference/policies/base/ub.md index f6f4612122b..d9e81db8bb9 100644 --- a/doc/src/content/reference/policies/base/ub.md +++ b/doc/src/content/reference/policies/base/ub.md @@ -9,7 +9,7 @@ This is a special function which does compiler-specific stuff to tell the compil This may seem highly undesirable. However, it also means that the optimiser can optimise more strongly, and so long as you never actually do execute this branch, you do get higher quality code generation. -If the `NDEBUG` macro is not defined, an `assert(false)` is present. This will cause attempts to execute this function to fail in a very obvious way, but it also generates runtime code to trigger the obvious failure. +If the `NDEBUG` macro is not defined, an `OUTCOME_ASSERT(false)` is present. This will cause attempts to execute this function to fail in a very obvious way, but it also generates runtime code to trigger the obvious failure. If the `NDEBUG` macro is defined, and the program is compiled with the undefined behaviour sanitiser, attempts to execute this function will trigger an undefined behaviour sanitiser action. diff --git a/include/outcome/config.hpp b/include/outcome/config.hpp index 23d99ec4f9e..b0815153998 100644 --- a/include/outcome/config.hpp +++ b/include/outcome/config.hpp @@ -55,7 +55,7 @@ Distributed under the Boost Software License, Version 1.0. #define OUTCOME_TEXPR(...) typename = decltype(__VA_ARGS__) #define OUTCOME_TPRED(...) typename = std::enable_if_t<__VA_ARGS__> #define OUTCOME_REQUIRES(...) requires __VA_ARGS__ -/*! AWAITING HUGO JSON CONVERSION TOOL +/*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ #endif @@ -157,14 +157,14 @@ using std::in_place_type; OUTCOME_V2_NAMESPACE_END #else OUTCOME_V2_NAMESPACE_BEGIN -/*! AWAITING HUGO JSON CONVERSION TOOL +/*! AWAITING HUGO JSON CONVERSION TOOL type definition template in_place_type_t. Potential doc page: `in_place_type_t` */ template struct in_place_type_t { explicit in_place_type_t() = default; }; -/*! AWAITING HUGO JSON CONVERSION TOOL +/*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ template constexpr in_place_type_t in_place_type{}; @@ -178,6 +178,11 @@ OUTCOME_V2_NAMESPACE_END #define OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__) #endif +#ifndef OUTCOME_ASSERT +#include +#define OUTCOME_ASSERT(...) assert(__VA_ARGS__) +#endif + #ifndef OUTCOME_TRIVIAL_ABI #if defined(STANDARDESE_IS_IN_THE_HOUSE) || __clang_major__ >= 7 //! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. @@ -353,11 +358,11 @@ namespace detail { #if !defined(OUTCOME_DISABLE_EXECINFO) void *bt[16]; - size_t btlen = backtrace(bt, sizeof(bt) / sizeof(bt[0])); // NOLINT + size_t btlen = backtrace(bt, sizeof(bt) / sizeof(bt[0])); // NOLINT #endif fprintf(stderr, "FATAL: Outcome throws exception %s with exceptions disabled\n", expr); // NOLINT #if !defined(OUTCOME_DISABLE_EXECINFO) - char **bts = backtrace_symbols(bt, btlen); // NOLINT + char **bts = backtrace_symbols(bt, btlen); // NOLINT if(bts != nullptr) { for(size_t n = 0; n < btlen; n++) diff --git a/include/outcome/detail/coroutine_support.ipp b/include/outcome/detail/coroutine_support.ipp index 3a98419a3d7..eefea1081a3 100644 --- a/include/outcome/detail/coroutine_support.ipp +++ b/include/outcome/detail/coroutine_support.ipp @@ -30,7 +30,6 @@ Distributed under the Boost Software License, Version 1.0. #define OUTCOME_DETAIL_COROUTINE_SUPPORT_HPP #include -#include #include #ifndef OUTCOME_COROUTINE_HEADER_TYPE @@ -209,7 +208,7 @@ namespace awaitables void return_value(container_type &&value) { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns value"); - assert(!result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire)); if(result_set.load(std::memory_order_acquire)) { result.~container_type(); // could throw @@ -220,7 +219,7 @@ namespace awaitables void return_value(const container_type &value) { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns value"); - assert(!result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire)); if(result_set.load(std::memory_order_acquire)) { result.~container_type(); // could throw @@ -231,7 +230,7 @@ namespace awaitables void unhandled_exception() { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise unhandled exception"); - assert(!result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire)); if(result_set.load(std::memory_order_acquire)) { result.~container_type(); @@ -323,13 +322,13 @@ namespace awaitables void return_void() noexcept { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns void"); - assert(!result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire)); result_set.store(true, std::memory_order_release); } void unhandled_exception() { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise unhandled exception"); - assert(!result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire)); std::rethrow_exception(std::current_exception()); // throws } auto initial_suspend() noexcept @@ -431,7 +430,7 @@ namespace awaitables container_type await_resume() { OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(&_h.promise() << " await_resume"); - assert(_h.promise().result_set.load(std::memory_order_acquire)); + OUTCOME_ASSERT(_h.promise().result_set.load(std::memory_order_acquire)); if(!_h.promise().result_set.load(std::memory_order_acquire)) { std::terminate(); @@ -507,7 +506,7 @@ namespace awaitables } void return_void() noexcept { - assert(result_set.load(std::memory_order_acquire) >= 0); + OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0); if(result_set.load(std::memory_order_acquire) == 1) { result.~container_type(); // could throw @@ -516,7 +515,7 @@ namespace awaitables } suspend_always yield_value(container_type &&value) { - assert(result_set.load(std::memory_order_acquire) >= 0); + OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0); if(result_set.load(std::memory_order_acquire) == 1) { result.~container_type(); // could throw @@ -527,7 +526,7 @@ namespace awaitables } suspend_always yield_value(const container_type &value) { - assert(result_set.load(std::memory_order_acquire) >= 0); + OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0); if(result_set.load(std::memory_order_acquire) == 1) { result.~container_type(); // could throw @@ -538,7 +537,7 @@ namespace awaitables } void unhandled_exception() { - assert(result_set.load(std::memory_order_acquire) >= 0); + OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0); if(result_set.load(std::memory_order_acquire) == 1) { result.~container_type(); @@ -631,7 +630,7 @@ namespace awaitables { _h(); } - assert(p.result_set.load(std::memory_order_acquire) >= 0); + OUTCOME_ASSERT(p.result_set.load(std::memory_order_acquire) >= 0); if(p.result_set.load(std::memory_order_acquire) < 0) { std::terminate(); diff --git a/include/outcome/detail/revision.hpp b/include/outcome/detail/revision.hpp index b645b4a04ff..b4e9650d605 100644 --- a/include/outcome/detail/revision.hpp +++ b/include/outcome/detail/revision.hpp @@ -22,6 +22,6 @@ Distributed under the Boost Software License, Version 1.0. */ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define OUTCOME_PREVIOUS_COMMIT_REF f7892ac2e8ef0a236f324a9111e75824ae55690a -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-11-17 08:58:53 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f7892ac2 +#define OUTCOME_PREVIOUS_COMMIT_REF 645500fe31c7ffc14299af9651b2ae1c9d6741c9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 20:11:33 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 645500fe diff --git a/include/outcome/detail/value_storage.hpp b/include/outcome/detail/value_storage.hpp index 0be2d1847e1..d534f4b4032 100644 --- a/include/outcome/detail/value_storage.hpp +++ b/include/outcome/detail/value_storage.hpp @@ -27,8 +27,6 @@ Distributed under the Boost Software License, Version 1.0. #include "../config.hpp" -#include - OUTCOME_V2_NAMESPACE_EXPORT_BEGIN namespace detail @@ -50,7 +48,7 @@ namespace detail // But fall back on default construction and move assign if necessary template struct move_assign_to_empty { - move_assign_to_empty(T *dest, T *o) noexcept(std::is_nothrow_default_constructible::value &&std::is_nothrow_move_assignable::value) + move_assign_to_empty(T *dest, T *o) noexcept(std::is_nothrow_default_constructible::value && std::is_nothrow_move_assignable::value) { new(dest) T; *dest = static_cast(*o); @@ -71,7 +69,7 @@ namespace detail }; // Helpers for copy assigning to empty storage template ::value, - bool isDefaultConstructibleAndCopyAssignable = std::is_default_constructible::value &&std::is_copy_assignable::value> + bool isDefaultConstructibleAndCopyAssignable = std::is_default_constructible::value && std::is_copy_assignable::value> struct copy_assign_to_empty; // Prefer to use copy construction template struct copy_assign_to_empty @@ -85,7 +83,7 @@ namespace detail // But fall back on default construction and copy assign if necessary template struct copy_assign_to_empty { - copy_assign_to_empty(T *dest, const T *o) noexcept(std::is_nothrow_default_constructible::value &&std::is_nothrow_copy_assignable::value) + copy_assign_to_empty(T *dest, const T *o) noexcept(std::is_nothrow_default_constructible::value && std::is_nothrow_copy_assignable::value) { new(dest) T; *dest = *o; @@ -237,7 +235,7 @@ namespace detail #endif void make_ub(T && /*unused*/) { - assert(false); // NOLINT + OUTCOME_ASSERT(false); // NOLINT #if defined(__GNUC__) || defined(__clang__) __builtin_unreachable(); #elif defined(_MSC_VER) @@ -927,8 +925,9 @@ namespace detail && detail::is_constructible && detail::is_constructible; OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) - constexpr explicit value_storage_trivial(const value_storage_trivial &o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + constexpr explicit value_storage_trivial(const value_storage_trivial &o, + nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept(detail::is_nothrow_constructible<_value_type_, U> && + detail::is_nothrow_constructible<_error_type_, V>) : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type, o._value) : (o._status.have_error() ? value_storage_trivial(in_place_type, o._error) : value_storage_trivial())) // NOLINT @@ -937,8 +936,9 @@ namespace detail } OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) - constexpr explicit value_storage_trivial(value_storage_trivial &&o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + constexpr explicit value_storage_trivial(value_storage_trivial &&o, + nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept(detail::is_nothrow_constructible<_value_type_, U> && + detail::is_nothrow_constructible<_error_type_, V>) : value_storage_trivial( o._status.have_value() ? value_storage_trivial(in_place_type, static_cast(o._value)) : @@ -951,11 +951,12 @@ namespace detail { }; template - static constexpr bool enable_void_value_converting_constructor = std::is_default_constructible::value &&detail::is_constructible; + static constexpr bool enable_void_value_converting_constructor = + std::is_default_constructible::value && detail::is_constructible; OUTCOME_TEMPLATE(class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_value_converting_constructor)) constexpr explicit value_storage_trivial(const value_storage_trivial &o, void_value_converting_constructor_tag /*unused*/ = {}) noexcept( - std::is_nothrow_default_constructible<_value_type_>::value &&detail::is_nothrow_constructible<_error_type_, V>) + std::is_nothrow_default_constructible<_value_type_>::value && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type) : (o._status.have_error() ? value_storage_trivial(in_place_type, o._error) : value_storage_trivial())) // NOLINT @@ -965,7 +966,7 @@ namespace detail OUTCOME_TEMPLATE(class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_value_converting_constructor)) constexpr explicit value_storage_trivial(value_storage_trivial &&o, void_value_converting_constructor_tag /*unused*/ = {}) noexcept( - std::is_nothrow_default_constructible<_value_type_>::value &&detail::is_nothrow_constructible<_error_type_, V>) + std::is_nothrow_default_constructible<_value_type_>::value && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_trivial( o._status.have_value() ? value_storage_trivial(in_place_type) : @@ -978,11 +979,12 @@ namespace detail { }; template - static constexpr bool enable_void_error_converting_constructor = std::is_default_constructible::value &&detail::is_constructible; + static constexpr bool enable_void_error_converting_constructor = + std::is_default_constructible::value && detail::is_constructible; OUTCOME_TEMPLATE(class U) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_error_converting_constructor)) constexpr explicit value_storage_trivial(const value_storage_trivial &o, void_error_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&std::is_nothrow_default_constructible<_error_type_>::value) + detail::is_nothrow_constructible<_value_type_, U> && std::is_nothrow_default_constructible<_error_type_>::value) : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type, o._value) : (o._status.have_error() ? value_storage_trivial(in_place_type) : value_storage_trivial())) // NOLINT @@ -992,7 +994,7 @@ namespace detail OUTCOME_TEMPLATE(class U) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_error_converting_constructor)) constexpr explicit value_storage_trivial(value_storage_trivial &&o, void_error_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&std::is_nothrow_default_constructible<_error_type_>::value) + detail::is_nothrow_constructible<_value_type_, U> && std::is_nothrow_default_constructible<_error_type_>::value) : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type, static_cast(o._value)) : (o._status.have_error() ? value_storage_trivial(in_place_type) : value_storage_trivial())) // NOLINT @@ -1050,8 +1052,8 @@ namespace detail #if __cplusplus >= 202000L || _HAS_CXX20 constexpr #endif - value_storage_nontrivial(value_storage_nontrivial &&o) noexcept( - std::is_nothrow_move_constructible<_value_type_>::value &&std::is_nothrow_move_constructible<_error_type_>::value) // NOLINT + value_storage_nontrivial(value_storage_nontrivial &&o) noexcept(std::is_nothrow_move_constructible<_value_type_>::value && + std::is_nothrow_move_constructible<_error_type_>::value) // NOLINT { if(o._status.have_value()) { @@ -1067,8 +1069,8 @@ namespace detail #if __cplusplus >= 202000L || _HAS_CXX20 constexpr #endif - value_storage_nontrivial(const value_storage_nontrivial &o) noexcept( - std::is_nothrow_copy_constructible<_value_type_>::value &&std::is_nothrow_copy_constructible<_error_type_>::value) + value_storage_nontrivial(const value_storage_nontrivial &o) noexcept(std::is_nothrow_copy_constructible<_value_type_>::value && + std::is_nothrow_copy_constructible<_error_type_>::value) { if(o._status.have_value()) { @@ -1130,7 +1132,7 @@ namespace detail OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) constexpr explicit value_storage_nontrivial(const value_storage_trivial &o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + detail::is_nothrow_constructible<_value_type_, U> && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, o._value) : (o._status.have_error() ? value_storage_nontrivial(in_place_type, o._error) : value_storage_nontrivial())) @@ -1140,7 +1142,7 @@ namespace detail OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) constexpr explicit value_storage_nontrivial(value_storage_trivial &&o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + detail::is_nothrow_constructible<_value_type_, U> && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_nontrivial( o._status.have_value() ? value_storage_nontrivial(in_place_type, static_cast(o._value)) : @@ -1151,7 +1153,7 @@ namespace detail OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) constexpr explicit value_storage_nontrivial(const value_storage_nontrivial &o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + detail::is_nothrow_constructible<_value_type_, U> && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, o._value) : (o._status.have_error() ? value_storage_nontrivial(in_place_type, o._error) : value_storage_nontrivial())) @@ -1161,7 +1163,7 @@ namespace detail OUTCOME_TEMPLATE(class U, class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_nonvoid_converting_constructor)) constexpr explicit value_storage_nontrivial(value_storage_nontrivial &&o, nonvoid_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&detail::is_nothrow_constructible<_error_type_, V>) + detail::is_nothrow_constructible<_value_type_, U> && detail::is_nothrow_constructible<_error_type_, V>) : value_storage_nontrivial( o._status.have_value() ? value_storage_nontrivial(in_place_type, static_cast(o._value)) : @@ -1174,11 +1176,12 @@ namespace detail { }; template - static constexpr bool enable_void_value_converting_constructor = std::is_default_constructible::value &&detail::is_constructible; + static constexpr bool enable_void_value_converting_constructor = + std::is_default_constructible::value && detail::is_constructible; OUTCOME_TEMPLATE(class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_value_converting_constructor)) constexpr explicit value_storage_nontrivial(const value_storage_trivial &o, void_value_converting_constructor_tag /*unused*/ = {}) noexcept( - std::is_nothrow_default_constructible<_value_type_>::value &&detail::is_nothrow_constructible<_error_type_, V>) + std::is_nothrow_default_constructible<_value_type_>::value && detail::is_nothrow_constructible<_error_type_, V>) { if(o._status.have_value()) { @@ -1193,7 +1196,7 @@ namespace detail OUTCOME_TEMPLATE(class V) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_value_converting_constructor)) constexpr explicit value_storage_nontrivial(value_storage_trivial &&o, void_value_converting_constructor_tag /*unused*/ = {}) noexcept( - std::is_nothrow_default_constructible<_value_type_>::value &&detail::is_nothrow_constructible<_error_type_, V>) + std::is_nothrow_default_constructible<_value_type_>::value && detail::is_nothrow_constructible<_error_type_, V>) { if(o._status.have_value()) { @@ -1211,11 +1214,12 @@ namespace detail { }; template - static constexpr bool enable_void_error_converting_constructor = std::is_default_constructible::value &&detail::is_constructible; + static constexpr bool enable_void_error_converting_constructor = + std::is_default_constructible::value && detail::is_constructible; OUTCOME_TEMPLATE(class U) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_error_converting_constructor)) constexpr explicit value_storage_nontrivial(const value_storage_trivial &o, void_error_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&std::is_nothrow_default_constructible<_error_type_>::value) + detail::is_nothrow_constructible<_value_type_, U> && std::is_nothrow_default_constructible<_error_type_>::value) { if(o._status.have_value()) { @@ -1230,7 +1234,7 @@ namespace detail OUTCOME_TEMPLATE(class U) OUTCOME_TREQUIRES(OUTCOME_TPRED(enable_void_error_converting_constructor)) constexpr explicit value_storage_nontrivial(value_storage_trivial &&o, void_error_converting_constructor_tag /*unused*/ = {}) noexcept( - detail::is_nothrow_constructible<_value_type_, U> &&std::is_nothrow_default_constructible<_error_type_>::value) + detail::is_nothrow_constructible<_value_type_, U> && std::is_nothrow_default_constructible<_error_type_>::value) { if(o._status.have_value()) { @@ -1247,7 +1251,7 @@ namespace detail #if __cplusplus >= 202000L || _HAS_CXX20 constexpr #endif - ~value_storage_nontrivial() noexcept(std::is_nothrow_destructible<_value_type_>::value &&std::is_nothrow_destructible<_error_type_>::value) + ~value_storage_nontrivial() noexcept(std::is_nothrow_destructible<_value_type_>::value && std::is_nothrow_destructible<_error_type_>::value) { if(this->_status.have_value()) { @@ -1270,7 +1274,7 @@ namespace detail constexpr #endif void - swap(value_storage_nontrivial &o) noexcept(detail::is_nothrow_swappable<_value_type_>::value &&detail::is_nothrow_swappable<_error_type_>::value) + swap(value_storage_nontrivial &o) noexcept(detail::is_nothrow_swappable<_value_type_>::value && detail::is_nothrow_swappable<_error_type_>::value) { using std::swap; // empty/empty @@ -1468,10 +1472,11 @@ namespace detail #endif value_storage_nontrivial_move_assignment & operator=(value_storage_nontrivial_move_assignment &&o) noexcept( - std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable::value &&noexcept(move_assign_to_empty( + std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value && noexcept(move_assign_to_empty( static_cast(nullptr), - static_cast(nullptr))) &&noexcept(move_assign_to_empty(static_cast(nullptr), - static_cast(nullptr)))) // NOLINT + static_cast(nullptr))) && noexcept(move_assign_to_empty(static_cast(nullptr), + static_cast(nullptr)))) // NOLINT { using _value_type_ = typename Base::_value_type_; using _error_type_ = typename Base::_error_type_; @@ -1570,9 +1575,10 @@ namespace detail #endif value_storage_nontrivial_copy_assignment & operator=(const value_storage_nontrivial_copy_assignment &o) noexcept( - std::is_nothrow_copy_assignable::value &&std::is_nothrow_copy_assignable::value &&noexcept(copy_assign_to_empty( - static_cast(nullptr), static_cast(nullptr))) &&noexcept(copy_assign_to_empty(static_cast(nullptr), - static_cast(nullptr)))) + std::is_nothrow_copy_assignable::value && + std::is_nothrow_copy_assignable::value && noexcept(copy_assign_to_empty( + static_cast(nullptr), static_cast(nullptr))) && noexcept(copy_assign_to_empty(static_cast(nullptr), + static_cast(nullptr)))) { using _value_type_ = typename Base::_value_type_; using _error_type_ = typename Base::_error_type_; @@ -1705,8 +1711,8 @@ namespace detail #ifndef NDEBUG // Check is trivial in all ways except default constructibility // static_assert(std::is_trivial>::value, "value_storage_select_impl is not trivial!"); - // static_assert(std::is_trivially_default_constructible>::value, "value_storage_select_impl is not trivially - // default constructible!"); + // static_assert(std::is_trivially_default_constructible>::value, "value_storage_select_impl is not + // trivially default constructible!"); static_assert(std::is_trivially_copyable>::value, "value_storage_select_impl is not trivially copyable!"); static_assert(std::is_trivially_assignable, value_storage_select_impl>::value, "value_storage_select_impl is not trivially assignable!"); diff --git a/include/outcome/detail/version.hpp b/include/outcome/detail/version.hpp index ae6ec1cd4a0..da8301e9e8d 100644 --- a/include/outcome/detail/version.hpp +++ b/include/outcome/detail/version.hpp @@ -1,5 +1,5 @@ /* Sets Outcome version -(C) 2017-2019 Niall Douglas (4 commits) +(C) 2017-2023 Niall Douglas (4 commits) Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ Distributed under the Boost Software License, Version 1.0. /*! AWAITING HUGO JSON CONVERSION TOOL */ #define OUTCOME_VERSION_MINOR 2 /*! AWAITING HUGO JSON CONVERSION TOOL */ -#define OUTCOME_VERSION_PATCH 8 +#define OUTCOME_VERSION_PATCH 9 /*! AWAITING HUGO JSON CONVERSION TOOL */ #define OUTCOME_VERSION_REVISION 0 // Revision version for cmake and DLL version stamping diff --git a/include/outcome/try.hpp b/include/outcome/try.hpp index b668ffb5cf2..dc58a1a42f9 100644 --- a/include/outcome/try.hpp +++ b/include/outcome/try.hpp @@ -49,30 +49,60 @@ namespace detail struct value_overload { }; - //#ifdef __APPLE__ - // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) - //#else + // #ifdef __APPLE__ + // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) + // #else OUTCOME_TEMPLATE(class T, class R = decltype(std::declval().as_failure())) - //#endif + // #endif OUTCOME_TREQUIRES(OUTCOME_TPRED(OUTCOME_V2_NAMESPACE::is_failure_type)) - constexpr inline bool has_as_failure(int /*unused */) { return true; } - template constexpr inline bool has_as_failure(...) { return false; } + constexpr inline bool has_as_failure(int /*unused */) + { + return true; + } + template constexpr inline bool has_as_failure(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_error())) - constexpr inline bool has_assume_error(int /*unused */) { return true; } - template constexpr inline bool has_assume_error(...) { return false; } + constexpr inline bool has_assume_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().error())) - constexpr inline bool has_error(int /*unused */) { return true; } - template constexpr inline bool has_error(...) { return false; } + constexpr inline bool has_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_value())) - constexpr inline bool has_assume_value(int /*unused */) { return true; } - template constexpr inline bool has_assume_value(...) { return false; } + constexpr inline bool has_assume_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_value(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().value())) - constexpr inline bool has_value(int /*unused */) { return true; } - template constexpr inline bool has_value(...) { return false; } + constexpr inline bool has_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_value(...) + { + return false; + } } // namespace detail /*! AWAITING HUGO JSON CONVERSION TOOL diff --git a/single-header/outcome-basic.hpp b/single-header/outcome-basic.hpp index ef1b8e16351..2f0a3a8153b 100644 --- a/single-header/outcome-basic.hpp +++ b/single-header/outcome-basic.hpp @@ -1019,9 +1019,9 @@ Distributed under the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt) */ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define OUTCOME_PREVIOUS_COMMIT_REF f7892ac2e8ef0a236f324a9111e75824ae55690a -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-11-17 08:58:53 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f7892ac2 +#define OUTCOME_PREVIOUS_COMMIT_REF 645500fe31c7ffc14299af9651b2ae1c9d6741c9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 20:11:33 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 645500fe #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2)) #ifdef _DEBUG #define OUTCOME_V2_CXX_MODULE_NAME QUICKCPPLIB_BIND_NAMESPACE((QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2d))) @@ -6199,30 +6199,60 @@ namespace detail struct value_overload { }; - //#ifdef __APPLE__ - // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) - //#else + // #ifdef __APPLE__ + // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) + // #else OUTCOME_TEMPLATE(class T, class R = decltype(std::declval().as_failure())) - //#endif + // #endif OUTCOME_TREQUIRES(OUTCOME_TPRED(OUTCOME_V2_NAMESPACE::is_failure_type)) - constexpr inline bool has_as_failure(int /*unused */) { return true; } - template constexpr inline bool has_as_failure(...) { return false; } + constexpr inline bool has_as_failure(int /*unused */) + { + return true; + } + template constexpr inline bool has_as_failure(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_error())) - constexpr inline bool has_assume_error(int /*unused */) { return true; } - template constexpr inline bool has_assume_error(...) { return false; } + constexpr inline bool has_assume_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().error())) - constexpr inline bool has_error(int /*unused */) { return true; } - template constexpr inline bool has_error(...) { return false; } + constexpr inline bool has_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_value())) - constexpr inline bool has_assume_value(int /*unused */) { return true; } - template constexpr inline bool has_assume_value(...) { return false; } + constexpr inline bool has_assume_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_value(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().value())) - constexpr inline bool has_value(int /*unused */) { return true; } - template constexpr inline bool has_value(...) { return false; } + constexpr inline bool has_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_value(...) + { + return false; + } } // namespace detail /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED diff --git a/single-header/outcome-experimental.hpp b/single-header/outcome-experimental.hpp index 74afc8402a4..731d488a59d 100644 --- a/single-header/outcome-experimental.hpp +++ b/single-header/outcome-experimental.hpp @@ -1044,9 +1044,9 @@ Distributed under the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt) */ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define OUTCOME_PREVIOUS_COMMIT_REF f7892ac2e8ef0a236f324a9111e75824ae55690a -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-11-17 08:58:53 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f7892ac2 +#define OUTCOME_PREVIOUS_COMMIT_REF 645500fe31c7ffc14299af9651b2ae1c9d6741c9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 20:11:33 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 645500fe #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2)) #ifdef _DEBUG #define OUTCOME_V2_CXX_MODULE_NAME QUICKCPPLIB_BIND_NAMESPACE((QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2d))) @@ -11452,30 +11452,60 @@ namespace detail struct value_overload { }; - //#ifdef __APPLE__ - // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) - //#else + // #ifdef __APPLE__ + // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) + // #else OUTCOME_TEMPLATE(class T, class R = decltype(std::declval().as_failure())) - //#endif + // #endif OUTCOME_TREQUIRES(OUTCOME_TPRED(OUTCOME_V2_NAMESPACE::is_failure_type)) - constexpr inline bool has_as_failure(int /*unused */) { return true; } - template constexpr inline bool has_as_failure(...) { return false; } + constexpr inline bool has_as_failure(int /*unused */) + { + return true; + } + template constexpr inline bool has_as_failure(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_error())) - constexpr inline bool has_assume_error(int /*unused */) { return true; } - template constexpr inline bool has_assume_error(...) { return false; } + constexpr inline bool has_assume_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().error())) - constexpr inline bool has_error(int /*unused */) { return true; } - template constexpr inline bool has_error(...) { return false; } + constexpr inline bool has_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_value())) - constexpr inline bool has_assume_value(int /*unused */) { return true; } - template constexpr inline bool has_assume_value(...) { return false; } + constexpr inline bool has_assume_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_value(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().value())) - constexpr inline bool has_value(int /*unused */) { return true; } - template constexpr inline bool has_value(...) { return false; } + constexpr inline bool has_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_value(...) + { + return false; + } } // namespace detail /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED diff --git a/single-header/outcome.hpp b/single-header/outcome.hpp index 494383cbcb8..0e63bfd2992 100644 --- a/single-header/outcome.hpp +++ b/single-header/outcome.hpp @@ -1043,9 +1043,9 @@ Distributed under the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt) */ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define OUTCOME_PREVIOUS_COMMIT_REF f7892ac2e8ef0a236f324a9111e75824ae55690a -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-11-17 08:58:53 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f7892ac2 +#define OUTCOME_PREVIOUS_COMMIT_REF 645500fe31c7ffc14299af9651b2ae1c9d6741c9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 20:11:33 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 645500fe #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2)) #ifdef _DEBUG #define OUTCOME_V2_CXX_MODULE_NAME QUICKCPPLIB_BIND_NAMESPACE((QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2d))) @@ -8163,30 +8163,60 @@ namespace detail struct value_overload { }; - //#ifdef __APPLE__ - // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) - //#else + // #ifdef __APPLE__ + // OUTCOME_TEMPLATE(class T, class R = decltype(std::declval()._xcode_workaround_as_failure())) + // #else OUTCOME_TEMPLATE(class T, class R = decltype(std::declval().as_failure())) - //#endif + // #endif OUTCOME_TREQUIRES(OUTCOME_TPRED(OUTCOME_V2_NAMESPACE::is_failure_type)) - constexpr inline bool has_as_failure(int /*unused */) { return true; } - template constexpr inline bool has_as_failure(...) { return false; } + constexpr inline bool has_as_failure(int /*unused */) + { + return true; + } + template constexpr inline bool has_as_failure(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_error())) - constexpr inline bool has_assume_error(int /*unused */) { return true; } - template constexpr inline bool has_assume_error(...) { return false; } + constexpr inline bool has_assume_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().error())) - constexpr inline bool has_error(int /*unused */) { return true; } - template constexpr inline bool has_error(...) { return false; } + constexpr inline bool has_error(int /*unused */) + { + return true; + } + template constexpr inline bool has_error(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().assume_value())) - constexpr inline bool has_assume_value(int /*unused */) { return true; } - template constexpr inline bool has_assume_value(...) { return false; } + constexpr inline bool has_assume_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_assume_value(...) + { + return false; + } OUTCOME_TEMPLATE(class T) OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval().value())) - constexpr inline bool has_value(int /*unused */) { return true; } - template constexpr inline bool has_value(...) { return false; } + constexpr inline bool has_value(int /*unused */) + { + return true; + } + template constexpr inline bool has_value(...) + { + return false; + } } // namespace detail /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED diff --git a/test/tests/issue0009.cpp b/test/tests/issue0009.cpp index 2e60c5e2ac6..8a34eb34b02 100644 --- a/test/tests/issue0009.cpp +++ b/test/tests/issue0009.cpp @@ -28,6 +28,7 @@ Distributed under the Boost Software License, Version 1.0. BOOST_OUTCOME_AUTO_TEST_CASE(issues / 0009 / test, "Alternative TRY macros?") { #ifdef OUTCOME_TRYX +#pragma GCC diagnostic ignored "-Wpedantic" using namespace OUTCOME_V2_NAMESPACE; struct udt // NOLINT { @@ -36,7 +37,8 @@ BOOST_OUTCOME_AUTO_TEST_CASE(issues / 0009 / test, "Alternative TRY macros?") udt(const udt &) = default; udt(udt &&) = default; }; - auto f = []() -> result { + auto f = []() -> result + { auto g = [] { return result(5); }; return udt(OUTCOME_TRYX(g())); }; diff --git a/test/tests/issue0291.cpp b/test/tests/issue0291.cpp index d306d449e4d..339e25a8a94 100644 --- a/test/tests/issue0291.cpp +++ b/test/tests/issue0291.cpp @@ -25,6 +25,8 @@ Distributed under the Boost Software License, Version 1.0. #include "quickcpplib/boost/test/unit_test.hpp" +#pragma clang diagnostic ignored "-Wunneeded-internal-declaration" + namespace { namespace outcome = OUTCOME_V2_NAMESPACE;