From f9e7477dec473dcacec09d7af7b321f25b6aeab6 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 14 Dec 2020 11:36:27 +0000 Subject: [PATCH] Initial round of upgrading tutorial and documentation for Outcome v2.2. --- doc/src/config.toml | 2 +- doc/src/content/_index.md | 10 +++++----- doc/src/content/changelog/_index.md | 21 ++++++++++++++------- doc/src/snippets/error_code_enums2.cpp | 2 +- doc/src/snippets/finale.cpp | 6 +++--- doc/src/snippets/foreign_try.cpp | 2 +- doc/src/snippets/intro_example.cpp | 2 +- doc/src/snippets/using_outcome.cpp | 2 +- include/outcome/detail/revision.hpp | 6 +++--- include/outcome/experimental/status-code | 2 +- include/outcome/outcome.natvis | 4 ++-- single-header/outcome-basic.hpp | 12 ++++++------ single-header/outcome-experimental.hpp | 20 +++++++++++--------- single-header/outcome.hpp | 12 ++++++------ 14 files changed, 56 insertions(+), 47 deletions(-) diff --git a/doc/src/config.toml b/doc/src/config.toml index 90fe95507f..8825785a8a 100644 --- a/doc/src/config.toml +++ b/doc/src/config.toml @@ -19,7 +19,7 @@ enableGitInfo = true [[menu.shortcuts]] pre = "

More

" - name = " Outcome 2.1 github repo" + name = " Outcome 2.2 github repo" identifier = "ds" url = "https://github.com/ned14/outcome" weight = 10 diff --git a/doc/src/content/_index.md b/doc/src/content/_index.md index a73ea5b64e..f9030626e5 100644 --- a/doc/src/content/_index.md +++ b/doc/src/content/_index.md @@ -7,13 +7,13 @@ title = "Home" {{% boost-copyright %}} {{% notice note %}} -The final release of Outcome v2.1 will be in Boost 1.75 (end of 2020). From Boost 1.76 -(start of 2021) onwards Outcome v2.2 shall become the default. Please consider upgrading -your code now to v2.2 using [the v2.1 => v2.2 upgrade guide]({{% relref "/changelog/upgrade_v21_v22" %}}). -The v2.2 branch has a number of major breaking changes to Outcome v2.1, see +At the end of December 2020, Outcome v2.2 replaced v2.1 in develop branch. This is a breaking +change and all Outcome v2.1 code will need to be upgraded using [the v2.1 => v2.2 upgrade guide]({{% relref "/changelog/upgrade_v21_v22" %}}). See also [the list of v2.2 major changes]({{% relref "/changelog/v22" %}}).

-This library's tutorial remains v2.1 based. It shall be ported to v2.2 in early 2021. +This library's tutorial is currently being converted from v2.1 to v2.2, so be aware some code +examples may not compile correctly yet. Once the documentation is fully upgraded, develop branch +shall be merged into master branch. {{% /notice %}} Outcome is a set of tools for reporting and handling function failures in contexts where *directly* using C++ exception handling is unsuitable. Such contexts include: diff --git a/doc/src/content/changelog/_index.md b/doc/src/content/changelog/_index.md index 43a34eff57..c3b5178892 100644 --- a/doc/src/content/changelog/_index.md +++ b/doc/src/content/changelog/_index.md @@ -4,16 +4,23 @@ weight = 80 +++ --- -## v2.1.5 11th December 2020 (Boost 1.75) [[release]](https://github.com/ned14/outcome/releases/tag/v2.1.5) +## v2.2.0 ? (Boost 1.76) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.0) -{{% notice note %}} -The v2.1 branch is expected to be retired end of 2020 with the Boost 1.75 release, with the v2.2 branch -becoming the default for Boost 1.76 onwards. You can use the future v2.2 branch now using -[`better_optimisation`](https://github.com/ned14/outcome/tree/better_optimisation), -how to upgrade your code is described in [the v2.1 => v2.2 upgrade guide]({{% relref "/changelog/upgrade_v21_v22" %}}). +BREAKING CHANGE As announced for a year and three Boost releases, Outcome v2.2 became the default, replacing v2.1. +: All v2.1 Outcome code will need to be upgraded as described in [the v2.1 => v2.2 upgrade guide]({{% relref "/changelog/upgrade_v21_v22" %}}). This branch has a number of major breaking changes to Outcome v2.1, see [the list of v2.2 major changes]({{% relref "/changelog/v22" %}}). -{{% /notice %}} + +### Enhancements: + +VS2019.8 compatibility +: VS2019.8 changed how to enable Coroutines, which caused Outcome to not compile on that compiler. + +### Bug fixes: + + +--- +## v2.1.5 11th December 2020 (Boost 1.75) [[release]](https://github.com/ned14/outcome/releases/tag/v2.1.5) ### Enhancements: diff --git a/doc/src/snippets/error_code_enums2.cpp b/doc/src/snippets/error_code_enums2.cpp index ba4ee523b6..2884e85ba5 100644 --- a/doc/src/snippets/error_code_enums2.cpp +++ b/doc/src/snippets/error_code_enums2.cpp @@ -128,7 +128,7 @@ result boo() } result foo() { - OUTCOME_TRY(auto &&v, (boo())); + OUTCOME_TRY(auto v, (boo())); return udt{5}; // emplace construct udt with 5 } //! [usage3] diff --git a/doc/src/snippets/finale.cpp b/doc/src/snippets/finale.cpp index ec07f7399e..13499df762 100644 --- a/doc/src/snippets/finale.cpp +++ b/doc/src/snippets/finale.cpp @@ -387,7 +387,7 @@ namespace app // that into a httplib_error exception type which is stored as an exception ptr. The // TRY operation below will return that exception ptr to be rethrown in the caller. // Otherwise the fetched data is returned in a std::string data. - OUTCOME_TRY(auto &&data, ext(httplib::get("http://www.nedproductions.biz/"))); + OUTCOME_TRY(auto data, ext(httplib::get("http://www.nedproductions.biz/"))); string_view data_view(data); // HTML tidy the fetched data. If the C library fails due to an error corresponding to @@ -397,11 +397,11 @@ namespace app // TRY operation below will return that exception ptr to be rethrown in the caller. // Otherwise the tidied data is returned into holdmem, with the string view updated to // point at the tidied data. - OUTCOME_TRY(auto &&holdmem, ext(tidy_html(data_view))); + OUTCOME_TRY(auto holdmem, ext(tidy_html(data_view))); // Write the tidied data to some file. If the write fails, synthesise a filesystem_error // exception ptr exactly as if one called filelib::write_file(data_view).value(). - OUTCOME_TRY(auto &&written, ext(filelib::write_file(data_view))); + OUTCOME_TRY(auto written, ext(filelib::write_file(data_view))); return success(); } } // namespace app diff --git a/doc/src/snippets/foreign_try.cpp b/doc/src/snippets/foreign_try.cpp index 0d301ae7af..984550834b 100644 --- a/doc/src/snippets/foreign_try.cpp +++ b/doc/src/snippets/foreign_try.cpp @@ -88,7 +88,7 @@ ForeignExpected old_code(int a) // old code outcome::result new_code(int a) // new code { - OUTCOME_TRY(auto &&x, old_code(a)); + OUTCOME_TRY(auto x, old_code(a)); return x; } //! [functions] diff --git a/doc/src/snippets/intro_example.cpp b/doc/src/snippets/intro_example.cpp index fc495c31c3..5857d4163f 100644 --- a/doc/src/snippets/intro_example.cpp +++ b/doc/src/snippets/intro_example.cpp @@ -57,7 +57,7 @@ outcome::result process(const string& content) noexcept; outcome::result int_from_file(string_view path) noexcept { - OUTCOME_TRY(auto &&str, data_from_file(path)); + OUTCOME_TRY(auto str, data_from_file(path)); // if control gets here data_from_file() has succeeded return process(str); // decltype(str) == string } diff --git a/doc/src/snippets/using_outcome.cpp b/doc/src/snippets/using_outcome.cpp index 72b3e992d4..6489e34fe2 100644 --- a/doc/src/snippets/using_outcome.cpp +++ b/doc/src/snippets/using_outcome.cpp @@ -49,7 +49,7 @@ namespace old //! [def_h] auto old::h() noexcept -> outcome::outcome { - OUTCOME_TRY(auto &&i, (g())); // #1 + OUTCOME_TRY(auto i, (g())); // #1 try { return i + f(); diff --git a/include/outcome/detail/revision.hpp b/include/outcome/detail/revision.hpp index fdfb8584be..aeffb70f62 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 6ca680fe10892cdd44173327a7e1bde12afc5784 -#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-10-09 09:48:05 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 6ca680fe +#define OUTCOME_PREVIOUS_COMMIT_REF bbde4ec13b1f9fec23d2ec2b1064e9295f4d9e27 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-12-14 10:10:19 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE bbde4ec1 diff --git a/include/outcome/experimental/status-code b/include/outcome/experimental/status-code index a9ef1d0aaa..6befe8f7c7 160000 --- a/include/outcome/experimental/status-code +++ b/include/outcome/experimental/status-code @@ -1 +1 @@ -Subproject commit a9ef1d0aaafd83937cdc2cba48aed62d2147f86f +Subproject commit 6befe8f7c79329b75a3b51e1ce28b5893b62b76d diff --git a/include/outcome/outcome.natvis b/include/outcome/outcome.natvis index bce945b951..5ca7bc3fe6 100644 --- a/include/outcome/outcome.natvis +++ b/include/outcome/outcome.natvis @@ -1,6 +1,6 @@ - + empty value {{{_state._value}}} error {{{_state._error}}} @@ -21,7 +21,7 @@ _ptr - + empty value {{{_state._value}}} error {{{_state._error}}} diff --git a/single-header/outcome-basic.hpp b/single-header/outcome-basic.hpp index a6887f9a93..47af185dec 100644 --- a/single-header/outcome-basic.hpp +++ b/single-header/outcome-basic.hpp @@ -545,9 +545,9 @@ Distributed under the Boost Software License, Version 1.0. #endif #ifndef QUICKCPPLIB_DISABLE_ABI_PERMUTATION // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define QUICKCPPLIB_PREVIOUS_COMMIT_REF 10bf175bddec2aac1bebec46475fc3e85d755843 -#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-10-27 16:17:30 +00:00" -#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE 10bf175b +#define QUICKCPPLIB_PREVIOUS_COMMIT_REF b1fac941934e8d9ac3e82b02cf1264a829860d32 +#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-11-25 14:28:07 +00:00" +#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE b1fac941 #endif #define QUICKCPPLIB_VERSION_GLUE2(a, b) a##b #define QUICKCPPLIB_VERSION_GLUE(a, b) QUICKCPPLIB_VERSION_GLUE2(a, b) @@ -961,9 +961,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 6ca680fe10892cdd44173327a7e1bde12afc5784 -#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-10-09 09:48:05 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 6ca680fe +#define OUTCOME_PREVIOUS_COMMIT_REF bbde4ec13b1f9fec23d2ec2b1064e9295f4d9e27 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-12-14 10:10:19 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE bbde4ec1 #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2, OUTCOME_PREVIOUS_COMMIT_UNIQUE)) #else #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2)) diff --git a/single-header/outcome-experimental.hpp b/single-header/outcome-experimental.hpp index 1d2f157e8f..96284bfa23 100644 --- a/single-header/outcome-experimental.hpp +++ b/single-header/outcome-experimental.hpp @@ -570,9 +570,9 @@ Distributed under the Boost Software License, Version 1.0. #endif #ifndef QUICKCPPLIB_DISABLE_ABI_PERMUTATION // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define QUICKCPPLIB_PREVIOUS_COMMIT_REF 10bf175bddec2aac1bebec46475fc3e85d755843 -#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-10-27 16:17:30 +00:00" -#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE 10bf175b +#define QUICKCPPLIB_PREVIOUS_COMMIT_REF b1fac941934e8d9ac3e82b02cf1264a829860d32 +#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-11-25 14:28:07 +00:00" +#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE b1fac941 #endif #define QUICKCPPLIB_VERSION_GLUE2(a, b) a##b #define QUICKCPPLIB_VERSION_GLUE(a, b) QUICKCPPLIB_VERSION_GLUE2(a, b) @@ -986,9 +986,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 6ca680fe10892cdd44173327a7e1bde12afc5784 -#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-10-09 09:48:05 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 6ca680fe +#define OUTCOME_PREVIOUS_COMMIT_REF bbde4ec13b1f9fec23d2ec2b1064e9295f4d9e27 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-12-14 10:10:19 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE bbde4ec1 #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2, OUTCOME_PREVIOUS_COMMIT_UNIQUE)) #else #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2)) @@ -6140,7 +6140,7 @@ Distributed under the Boost Software License, Version 1.0. #ifndef SYSTEM_ERROR2_STATUS_ERROR_HPP #define SYSTEM_ERROR2_STATUS_ERROR_HPP /* Proposed SG14 status_code -(C) 2018 - 2019 Niall Douglas (5 commits) +(C) 2018 - 2020 Niall Douglas (5 commits) File Created: Feb 2018 @@ -7005,6 +7005,8 @@ template <> class SYSTEM_ERROR2_TRIVIAL_ABI status_code : _domain(v) { } + // Used to work around triggering a ubsan failure. Do NOT remove! + constexpr const status_code_domain *_domain_ptr() const noexcept { return _domain; } public: //! Return the status code domain. constexpr const status_code_domain &domain() const noexcept { return *_domain; } @@ -7287,14 +7289,14 @@ template class SYSTEM_ERROR2_TRIVIAL_ABI status_code::value, bool>::type = true> constexpr status_code(const status_code &v) noexcept // NOLINT - : _base(typename _base::_value_type_constructor{}, &v.domain(), detail::erasure_cast(v.value())) + : _base(typename _base::_value_type_constructor{}, v._domain_ptr(), detail::erasure_cast(v.value())) { } //! Implicit move construction from any other status code if its value type is trivially copyable or move bitcopying and it would fit into our storage template ::value, bool>::type = true> SYSTEM_ERROR2_CONSTEXPR14 status_code(status_code &&v) noexcept // NOLINT - : _base(typename _base::_value_type_constructor{}, &v.domain(), detail::erasure_cast(v.value())) + : _base(typename _base::_value_type_constructor{}, v._domain_ptr(), detail::erasure_cast(v.value())) { v._domain = nullptr; } diff --git a/single-header/outcome.hpp b/single-header/outcome.hpp index 33ca47dc6f..a7720d32cb 100644 --- a/single-header/outcome.hpp +++ b/single-header/outcome.hpp @@ -571,9 +571,9 @@ Distributed under the Boost Software License, Version 1.0. #endif #ifndef QUICKCPPLIB_DISABLE_ABI_PERMUTATION // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define QUICKCPPLIB_PREVIOUS_COMMIT_REF 10bf175bddec2aac1bebec46475fc3e85d755843 -#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-10-27 16:17:30 +00:00" -#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE 10bf175b +#define QUICKCPPLIB_PREVIOUS_COMMIT_REF b1fac941934e8d9ac3e82b02cf1264a829860d32 +#define QUICKCPPLIB_PREVIOUS_COMMIT_DATE "2020-11-25 14:28:07 +00:00" +#define QUICKCPPLIB_PREVIOUS_COMMIT_UNIQUE b1fac941 #endif #define QUICKCPPLIB_VERSION_GLUE2(a, b) a##b #define QUICKCPPLIB_VERSION_GLUE(a, b) QUICKCPPLIB_VERSION_GLUE2(a, b) @@ -987,9 +987,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 6ca680fe10892cdd44173327a7e1bde12afc5784 -#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-10-09 09:48:05 +00:00" -#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 6ca680fe +#define OUTCOME_PREVIOUS_COMMIT_REF bbde4ec13b1f9fec23d2ec2b1064e9295f4d9e27 +#define OUTCOME_PREVIOUS_COMMIT_DATE "2020-12-14 10:10:19 +00:00" +#define OUTCOME_PREVIOUS_COMMIT_UNIQUE bbde4ec1 #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2, OUTCOME_PREVIOUS_COMMIT_UNIQUE)) #else #define OUTCOME_V2 (QUICKCPPLIB_BIND_NAMESPACE_VERSION(outcome_v2))