From cc6088dae7508db1a072bb7440a10da37967e935 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Sat, 15 Jul 2023 11:14:45 +0100 Subject: [PATCH] Use a preprocessor macro to control the use of std::addressof(), fixing #282. --- CMakeLists.txt | 4 +- doc/src/content/changelog/_index.md | 5 +- include/outcome/config.hpp | 7 ++ include/outcome/detail/revision.hpp | 6 +- include/outcome/detail/value_storage.hpp | 50 ++++++------- include/outcome/experimental/status-code | 2 +- .../outcome/experimental/status_result.hpp | 6 ++ include/outcome/iostream_support.hpp | 8 +- single-header/outcome-basic.hpp | 62 ++++++++------- single-header/outcome-experimental.hpp | 75 ++++++++++++------- single-header/outcome.hpp | 70 +++++++++-------- test/tests/core-result.cpp | 6 ++ 12 files changed, 175 insertions(+), 126 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2a9fb6f3a7..370e4c29083 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,7 +218,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test" AND NOT PROJECT_IS_DEPENDENCY) add_executable(${target_name} "${testsource}") if(NOT first_test_target_noexcept) set(first_test_target_noexcept ${target_name}) - elseif(${target_name} MATCHES "coroutine-support|fileopen|hooks") + elseif(${target_name} MATCHES "coroutine-support|fileopen|hooks|core-result") set_target_properties(${target_name} PROPERTIES DISABLE_PRECOMPILE_HEADERS On) elseif(COMMAND target_precompile_headers) target_precompile_headers(${target_name} REUSE_FROM ${first_test_target_noexcept}) @@ -249,7 +249,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test" AND NOT PROJECT_IS_DEPENDENCY) add_executable(${target_name} "${testsource}") if(NOT first_test_target_permissive) set(first_test_target_permissive ${target_name}) - elseif(${target_name} MATCHES "coroutine-support|fileopen") + elseif(${target_name} MATCHES "coroutine-support|fileopen|core-result") set_target_properties(${target_name} PROPERTIES DISABLE_PRECOMPILE_HEADERS On) elseif(COMMAND target_precompile_headers) target_precompile_headers(${target_name} REUSE_FROM ${first_test_target_permissive}) diff --git a/doc/src/content/changelog/_index.md b/doc/src/content/changelog/_index.md index 72a7bdd38fc..d25dfa08605 100644 --- a/doc/src/content/changelog/_index.md +++ b/doc/src/content/changelog/_index.md @@ -15,8 +15,9 @@ This as usual will cause minor breakage due to LEWG renaming of things. - Outcome previously took addresses of things not using `std::addressof()`, and until now nobody complained because custom `operator&` which doesn't return an address is an -abomination not used in much modern C++. But finally someone did complain, so it is fixed -for both normal Outcome and Experimental.Outcome. +abomination not used in much modern C++. But finally someone did complain, so +for both normal Outcome and Experimental.Outcome, if you set `OUTCOME_USE_STD_ADDRESSOF = 1`, +Outcome will use `std::addressof()` ### Bug fixes: diff --git a/include/outcome/config.hpp b/include/outcome/config.hpp index a2114369565..23d99ec4f9e 100644 --- a/include/outcome/config.hpp +++ b/include/outcome/config.hpp @@ -171,6 +171,13 @@ template constexpr in_place_type_t in_place_type{}; OUTCOME_V2_NAMESPACE_END #endif +#if OUTCOME_USE_STD_ADDRESSOF +#include // for std::addressof +#define OUTCOME_ADDRESS_OF(...) std::addressof(__VA_ARGS__) +#else +#define OUTCOME_ADDRESS_OF(...) (&__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. diff --git a/include/outcome/detail/revision.hpp b/include/outcome/detail/revision.hpp index bf1b2a5369f..ff9013ba5f4 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 44da28c59d85f2245230931b6c25725b679b556c -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-06-28 21:21:35 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 44da28c5 +#define OUTCOME_PREVIOUS_COMMIT_REF 06da8aa6452ede5600af3c4ed4781ebd631149f9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-07-15 10:37:16 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 06da8aa6 diff --git a/include/outcome/detail/value_storage.hpp b/include/outcome/detail/value_storage.hpp index 9e7d415ceae..0be2d1847e1 100644 --- a/include/outcome/detail/value_storage.hpp +++ b/include/outcome/detail/value_storage.hpp @@ -1055,11 +1055,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -1072,11 +1072,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -1182,11 +1182,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -1197,11 +1197,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -1219,11 +1219,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; } @@ -1234,11 +1234,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -1325,7 +1325,7 @@ namespace detail if(_status.have_value() && !o._status.have_error()) { // Move construct me into other - new(std::addressof(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_value.~value_type(); // NOLINT @@ -1336,7 +1336,7 @@ namespace detail if(o._status.have_value() && !_status.have_error()) { // Move construct other into me - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT if(!trait::is_move_bitcopying::value) { o._value.~value_type(); // NOLINT @@ -1347,7 +1347,7 @@ namespace detail if(_status.have_error() && !o._status.have_value()) { // Move construct me into other - new(std::addressof(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_error.~error_type(); // NOLINT @@ -1358,7 +1358,7 @@ namespace detail if(o._status.have_error() && !_status.have_value()) { // Move construct other into me - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT if(!trait::is_move_bitcopying::value) { o._error.~error_type(); // NOLINT @@ -1382,7 +1382,7 @@ namespace detail this->b.set_have_lost_consistency(true); } } - } _{_status, o._status, std::addressof(_value), std::addressof(o._value), std::addressof(_error), std::addressof(o._error)}; + } _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)}; if(_status.have_value() && o._status.have_error()) { strong_placement(_.all_good, _.o_value, _.value, [&_] { // @@ -1507,7 +1507,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -1524,7 +1524,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -1535,7 +1535,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -1546,7 +1546,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -1604,7 +1604,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -1619,7 +1619,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -1629,7 +1629,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -1639,7 +1639,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } diff --git a/include/outcome/experimental/status-code b/include/outcome/experimental/status-code index 1b2ec7864e6..6827965ade4 160000 --- a/include/outcome/experimental/status-code +++ b/include/outcome/experimental/status-code @@ -1 +1 @@ -Subproject commit 1b2ec7864e62b26f90ad3ae7cb4b0a3f6ff0722e +Subproject commit 6827965ade4e66a3fcd572976b97a01547e10efe diff --git a/include/outcome/experimental/status_result.hpp b/include/outcome/experimental/status_result.hpp index 22fc7918d0b..dcf94625ca8 100644 --- a/include/outcome/experimental/status_result.hpp +++ b/include/outcome/experimental/status_result.hpp @@ -28,6 +28,12 @@ Distributed under the Boost Software License, Version 1.0. #include "../basic_result.hpp" #include "../policy/fail_to_compile_observers.hpp" +#ifndef SYSTEM_ERROR2_USE_STD_ADDRESSOF +#if OUTCOME_USE_STD_ADDRESSOF +#define SYSTEM_ERROR2_USE_STD_ADDRESSOF 1 +#endif +#endif + #if __PCPP_ALWAYS_TRUE__ #include "status-code/include/status-code/system_error2.hpp" #elif !OUTCOME_USE_SYSTEM_STATUS_CODE && __has_include("status-code/include/status-code/system_error2.hpp") diff --git a/include/outcome/iostream_support.hpp b/include/outcome/iostream_support.hpp index 198ccef6070..0ab77326332 100644 --- a/include/outcome/iostream_support.hpp +++ b/include/outcome/iostream_support.hpp @@ -82,12 +82,12 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_value()) { - new(std::addressof(v._value)) decltype(v._value)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._value)) decltype(v._value)(); // NOLINT s >> v._value; // NOLINT } if(v._status.have_error()) { - new(std::addressof(v._error)) decltype(v._error)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._error)) decltype(v._error)(); // NOLINT s >> v._error; // NOLINT } return s; @@ -103,7 +103,7 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_error()) { - new(std::addressof(v._error)) decltype(v._error)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._error)) decltype(v._error)(); // NOLINT s >> v._error; // NOLINT } return s; @@ -119,7 +119,7 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_value()) { - new(std::addressof(v._value)) decltype(v._value)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._value)) decltype(v._value)(); // NOLINT s >> v._value; // NOLINT } return s; diff --git a/single-header/outcome-basic.hpp b/single-header/outcome-basic.hpp index 321aba0e95c..0c70ad14193 100644 --- a/single-header/outcome-basic.hpp +++ b/single-header/outcome-basic.hpp @@ -996,9 +996,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 44da28c59d85f2245230931b6c25725b679b556c -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-06-28 21:21:35 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 44da28c5 +#define OUTCOME_PREVIOUS_COMMIT_REF 06da8aa6452ede5600af3c4ed4781ebd631149f9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-07-15 10:37:16 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 06da8aa6 #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))) @@ -1059,6 +1059,12 @@ SIGNATURE NOT RECOGNISED template constexpr in_place_type_t in_place_type{}; OUTCOME_V2_NAMESPACE_END #endif +#if OUTCOME_USE_STD_ADDRESSOF +#include // for std::addressof +#define OUTCOME_ADDRESS_OF(...) std::addressof(__VA_ARGS__) +#else +#define OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__) +#endif #ifndef OUTCOME_TRIVIAL_ABI #if 0L || __clang_major__ >= 7 //! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. @@ -2623,11 +2629,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2640,11 +2646,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -2748,11 +2754,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -2763,11 +2769,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2784,11 +2790,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; } @@ -2799,11 +2805,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2889,7 +2895,7 @@ namespace detail if(_status.have_value() && !o._status.have_error()) { // Move construct me into other - new(std::addressof(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_value.~value_type(); // NOLINT @@ -2900,7 +2906,7 @@ namespace detail if(o._status.have_value() && !_status.have_error()) { // Move construct other into me - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT if(!trait::is_move_bitcopying::value) { o._value.~value_type(); // NOLINT @@ -2911,7 +2917,7 @@ namespace detail if(_status.have_error() && !o._status.have_value()) { // Move construct me into other - new(std::addressof(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_error.~error_type(); // NOLINT @@ -2922,7 +2928,7 @@ namespace detail if(o._status.have_error() && !_status.have_value()) { // Move construct other into me - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT if(!trait::is_move_bitcopying::value) { o._error.~error_type(); // NOLINT @@ -2946,7 +2952,7 @@ namespace detail this->b.set_have_lost_consistency(true); } } - } _{_status, o._status, std::addressof(_value), std::addressof(o._value), std::addressof(_error), std::addressof(o._error)}; + } _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)}; if(_status.have_value() && o._status.have_error()) { strong_placement(_.all_good, _.o_value, _.value, [&_] { // @@ -3071,7 +3077,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3088,7 +3094,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3099,7 +3105,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3110,7 +3116,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3168,7 +3174,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -3183,7 +3189,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -3193,7 +3199,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -3203,7 +3209,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } diff --git a/single-header/outcome-experimental.hpp b/single-header/outcome-experimental.hpp index 1383eb966f9..ebde74293a5 100644 --- a/single-header/outcome-experimental.hpp +++ b/single-header/outcome-experimental.hpp @@ -1021,9 +1021,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 44da28c59d85f2245230931b6c25725b679b556c -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-06-28 21:21:35 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 44da28c5 +#define OUTCOME_PREVIOUS_COMMIT_REF 06da8aa6452ede5600af3c4ed4781ebd631149f9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-07-15 10:37:16 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 06da8aa6 #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))) @@ -1084,6 +1084,12 @@ SIGNATURE NOT RECOGNISED template constexpr in_place_type_t in_place_type{}; OUTCOME_V2_NAMESPACE_END #endif +#if OUTCOME_USE_STD_ADDRESSOF +#include // for std::addressof +#define OUTCOME_ADDRESS_OF(...) std::addressof(__VA_ARGS__) +#else +#define OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__) +#endif #ifndef OUTCOME_TRIVIAL_ABI #if 0L || __clang_major__ >= 7 //! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. @@ -2648,11 +2654,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2665,11 +2671,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -2773,11 +2779,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -2788,11 +2794,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2809,11 +2815,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; } @@ -2824,11 +2830,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -2914,7 +2920,7 @@ namespace detail if(_status.have_value() && !o._status.have_error()) { // Move construct me into other - new(std::addressof(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_value.~value_type(); // NOLINT @@ -2925,7 +2931,7 @@ namespace detail if(o._status.have_value() && !_status.have_error()) { // Move construct other into me - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT if(!trait::is_move_bitcopying::value) { o._value.~value_type(); // NOLINT @@ -2936,7 +2942,7 @@ namespace detail if(_status.have_error() && !o._status.have_value()) { // Move construct me into other - new(std::addressof(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_error.~error_type(); // NOLINT @@ -2947,7 +2953,7 @@ namespace detail if(o._status.have_error() && !_status.have_value()) { // Move construct other into me - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT if(!trait::is_move_bitcopying::value) { o._error.~error_type(); // NOLINT @@ -2971,7 +2977,7 @@ namespace detail this->b.set_have_lost_consistency(true); } } - } _{_status, o._status, std::addressof(_value), std::addressof(o._value), std::addressof(_error), std::addressof(o._error)}; + } _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)}; if(_status.have_value() && o._status.have_error()) { strong_placement(_.all_good, _.o_value, _.value, [&_] { // @@ -3096,7 +3102,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3113,7 +3119,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3124,7 +3130,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3135,7 +3141,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3193,7 +3199,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -3208,7 +3214,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -3218,7 +3224,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -3228,7 +3234,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -6273,6 +6279,11 @@ namespace policy #undef OUTCOME_FAIL_TO_COMPILE_OBSERVERS_MESSAGE OUTCOME_V2_NAMESPACE_END #endif +#ifndef SYSTEM_ERROR2_USE_STD_ADDRESSOF +#if OUTCOME_USE_STD_ADDRESSOF +#define SYSTEM_ERROR2_USE_STD_ADDRESSOF 1 +#endif +#endif /* Proposed SG14 status_code (C) 2018 Niall Douglas (5 commits) File Created: Feb 2018 @@ -6531,6 +6542,12 @@ Distributed under the Boost Software License, Version 1.0. #define SYSTEM_ERROR2_HAVE_BIT_CAST 0 #endif #endif +#if SYSTEM_ERROR2_USE_STD_ADDRESSOF +#include // for std::addressof +#define SYSTEM_ERROR2_ADDRESS_OF(...) std::addressof(__VA_ARGS__) +#else +#define SYSTEM_ERROR2_ADDRESS_OF(...) (&__VA_ARGS__) +#endif #ifndef SYSTEM_ERROR2_CONSTEXPR14 #if 0L || __cplusplus >= 201400 || _MSC_VER >= 1910 /* VS2017 */ //! Defined to be `constexpr` when on C++ 14 or better compilers. Usually automatic, can be overriden. @@ -11235,7 +11252,7 @@ namespace detail #endif { payload_allocator_traits::construct(payload_alloc, dp, sp.sc, sp.alloc); - new(std::addressof(d)) _mycode(in_place, dp); + new(SYSTEM_ERROR2_ADDRESS_OF(d)) _mycode(in_place, dp); } #if defined(_CPPUNWIND) || defined(__EXCEPTIONS) || 0L catch(...) diff --git a/single-header/outcome.hpp b/single-header/outcome.hpp index 349b8d15c0d..64419c41bf8 100644 --- a/single-header/outcome.hpp +++ b/single-header/outcome.hpp @@ -1020,9 +1020,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 44da28c59d85f2245230931b6c25725b679b556c -#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-06-28 21:21:35 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 44da28c5 +#define OUTCOME_PREVIOUS_COMMIT_REF 06da8aa6452ede5600af3c4ed4781ebd631149f9 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-07-15 10:37:16 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 06da8aa6 #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))) @@ -1083,6 +1083,12 @@ SIGNATURE NOT RECOGNISED template constexpr in_place_type_t in_place_type{}; OUTCOME_V2_NAMESPACE_END #endif +#if OUTCOME_USE_STD_ADDRESSOF +#include // for std::addressof +#define OUTCOME_ADDRESS_OF(...) std::addressof(__VA_ARGS__) +#else +#define OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__) +#endif #ifndef OUTCOME_TRIVIAL_ABI #if 0L || __clang_major__ >= 7 //! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. @@ -3457,11 +3463,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -3474,11 +3480,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -3582,11 +3588,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(o._error); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(o._error); // NOLINT } _status = o._status; } @@ -3597,11 +3603,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -3618,11 +3624,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(o._value); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(o._value); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; } @@ -3633,11 +3639,11 @@ namespace detail { if(o._status.have_value()) { - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT } else if(o._status.have_error()) { - new(std::addressof(_error)) _error_type_(); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(); // NOLINT } _status = o._status; o._status.set_have_moved_from(true); @@ -3723,7 +3729,7 @@ namespace detail if(_status.have_value() && !o._status.have_error()) { // Move construct me into other - new(std::addressof(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._value)) _value_type_(static_cast<_value_type_ &&>(_value)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_value.~value_type(); // NOLINT @@ -3734,7 +3740,7 @@ namespace detail if(o._status.have_value() && !_status.have_error()) { // Move construct other into me - new(std::addressof(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT + new(OUTCOME_ADDRESS_OF(_value)) _value_type_(static_cast<_value_type_ &&>(o._value)); // NOLINT if(!trait::is_move_bitcopying::value) { o._value.~value_type(); // NOLINT @@ -3745,7 +3751,7 @@ namespace detail if(_status.have_error() && !o._status.have_value()) { // Move construct me into other - new(std::addressof(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT + new(OUTCOME_ADDRESS_OF(o._error)) _error_type_(static_cast<_error_type_ &&>(_error)); // NOLINT if(!trait::is_move_bitcopying::value) { this->_error.~error_type(); // NOLINT @@ -3756,7 +3762,7 @@ namespace detail if(o._status.have_error() && !_status.have_value()) { // Move construct other into me - new(std::addressof(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT + new(OUTCOME_ADDRESS_OF(_error)) _error_type_(static_cast<_error_type_ &&>(o._error)); // NOLINT if(!trait::is_move_bitcopying::value) { o._error.~error_type(); // NOLINT @@ -3780,7 +3786,7 @@ namespace detail this->b.set_have_lost_consistency(true); } } - } _{_status, o._status, std::addressof(_value), std::addressof(o._value), std::addressof(_error), std::addressof(o._error)}; + } _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)}; if(_status.have_value() && o._status.have_error()) { strong_placement(_.all_good, _.o_value, _.value, [&_] { // @@ -3905,7 +3911,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3922,7 +3928,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3933,7 +3939,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - move_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + move_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -3944,7 +3950,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - move_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + move_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; o._status.set_have_moved_from(true); return *this; @@ -4002,7 +4008,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_value()) { - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -4017,7 +4023,7 @@ namespace detail } if(!this->_status.have_value() && !this->_status.have_error() && o._status.have_error()) { - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -4027,7 +4033,7 @@ namespace detail { this->_value.~_value_type_(); // NOLINT } - copy_assign_to_empty<_error_type_>(std::addressof(this->_error), std::addressof(o._error)); + copy_assign_to_empty<_error_type_>(OUTCOME_ADDRESS_OF(this->_error), OUTCOME_ADDRESS_OF(o._error)); this->_status = o._status; return *this; } @@ -4037,7 +4043,7 @@ namespace detail { this->_error.~_error_type_(); // NOLINT } - copy_assign_to_empty<_value_type_>(std::addressof(this->_value), std::addressof(o._value)); + copy_assign_to_empty<_value_type_>(OUTCOME_ADDRESS_OF(this->_value), OUTCOME_ADDRESS_OF(o._value)); this->_status = o._status; return *this; } @@ -7744,12 +7750,12 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_value()) { - new(std::addressof(v._value)) decltype(v._value)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._value)) decltype(v._value)(); // NOLINT s >> v._value; // NOLINT } if(v._status.have_error()) { - new(std::addressof(v._error)) decltype(v._error)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._error)) decltype(v._error)(); // NOLINT s >> v._error; // NOLINT } return s; @@ -7765,7 +7771,7 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_error()) { - new(std::addressof(v._error)) decltype(v._error)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._error)) decltype(v._error)(); // NOLINT s >> v._error; // NOLINT } return s; @@ -7781,7 +7787,7 @@ namespace detail v._status.spare_storage_value = y; if(v._status.have_value()) { - new(std::addressof(v._value)) decltype(v._value)(); // NOLINT + new(OUTCOME_ADDRESS_OF(v._value)) decltype(v._value)(); // NOLINT s >> v._value; // NOLINT } return s; diff --git a/test/tests/core-result.cpp b/test/tests/core-result.cpp index 9c4a0bfa685..cf45392c2c4 100644 --- a/test/tests/core-result.cpp +++ b/test/tests/core-result.cpp @@ -21,6 +21,8 @@ Distributed under the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt) */ +#define OUTCOME_USE_STD_ADDRESSOF 1 + #ifdef TESTING_WG21_EXPERIMENTAL_RESULT #include "../../include/outcome/experimental/result.hpp" #define BOOST_OUTCOME_AUTO_TEST_CASE(...) BOOST_AUTO_TEST_CASE(__VA_ARGS__) @@ -378,6 +380,8 @@ BOOST_OUTCOME_AUTO_TEST_CASE(works / result, "Tests that the result works as int result j3(j1); result j4(std::move(j0)); result j5(std::move(j1)); + (void) j3; + (void) j5; j2 = j0; j2 = j1; j2 = std::move(j0); @@ -390,6 +394,8 @@ BOOST_OUTCOME_AUTO_TEST_CASE(works / result, "Tests that the result works as int result k3(k1); result k4(std::move(k0)); result k5(std::move(k1)); + (void) k3; + (void) k5; k2 = k0; k2 = k1; k2 = std::move(k0);