Skip to content

Commit

Permalink
- Something I've been meaning to do for far too long now is make the …
Browse files Browse the repository at this point in the history
…GDB pretty printers

auto-loading so you don't have to set up `.gdbinit`. This is now done. I also improved
the pretty printers to also pretty print the C result type which can be very useful if
working with that type, as it will print the error message in GDB.

 Experimental Outcome's `status_code` has also gained its own auto-loading GDB pretty printer
with display of `strerror()` if the code domain is POSIX or generic.
  • Loading branch information
ned14 committed Jun 14, 2024
1 parent 571f9c9 commit c79bd04
Show file tree
Hide file tree
Showing 13 changed files with 1,302 additions and 501 deletions.
2 changes: 1 addition & 1 deletion doc/html
Submodule html updated 471 files
19 changes: 16 additions & 3 deletions doc/src/content/changelog/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ weight = 80
+++

---
## v2.2.9 ? (Boost 1.85) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.9)
## v2.2.10 ? (Boost 1.86) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.10)

### Enhancements:

- Something I've been meaning to do for far too long now is make the GDB pretty printers
auto-loading so you don't have to set up `.gdbinit`. This is now done. I also improved
the pretty printers to also pretty print the C result type which can be very useful if
working with that type, as it will print the error message in GDB.

Experimental Outcome's `status_code` has also gained its own auto-loading GDB pretty printer
with display of `strerror()` if the code domain is POSIX or generic.

### Bug fixes:

---
## v2.2.9 15th April 2024 (Boost 1.85) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.9)

### Enhancements:

Expand All @@ -24,8 +39,6 @@ realised at the time that in Boost.Outcome this resulted in
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)

Expand Down
96 changes: 52 additions & 44 deletions include/outcome/basic_outcome.hpp

Large diffs are not rendered by default.

66 changes: 41 additions & 25 deletions include/outcome/basic_result.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* A very simple result type
(C) 2017-2021 Niall Douglas <http://www.nedproductions.biz/> (14 commits)
(C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (14 commits)
File Created: June 2017
Expand Down Expand Up @@ -28,6 +28,7 @@ Distributed under the Boost Software License, Version 1.0.
#include "config.hpp"
#include "convert.hpp"
#include "detail/basic_result_final.hpp"
#include "outcome_gdb.h"

#include "policy/all_narrow.hpp"
#include "policy/terminate.hpp"
Expand Down Expand Up @@ -136,16 +137,31 @@ namespace detail
&& !std::is_same<choose_inplace_value_error_constructor<Args...>, disable_inplace_value_error_constructor>::value;
};

template <class T, class U> constexpr inline const U &extract_value_from_success(const success_type<U> &v) { return v.value(); }
template <class T, class U> constexpr inline U &&extract_value_from_success(success_type<U> &&v) { return static_cast<success_type<U> &&>(v).value(); }
template <class T> constexpr inline T extract_value_from_success(const success_type<void> & /*unused*/) { return T{}; }
template <class T, class U> constexpr inline const U &extract_value_from_success(const success_type<U> &v)
{
return v.value();
}
template <class T, class U> constexpr inline U &&extract_value_from_success(success_type<U> &&v)
{
return static_cast<success_type<U> &&>(v).value();
}
template <class T> constexpr inline T extract_value_from_success(const success_type<void> & /*unused*/)
{
return T{};
}

template <class T, class U, class V> constexpr inline const U &extract_error_from_failure(const failure_type<U, V> &v) { return v.error(); }
template <class T, class U, class V> constexpr inline const U &extract_error_from_failure(const failure_type<U, V> &v)
{
return v.error();
}
template <class T, class U, class V> constexpr inline U &&extract_error_from_failure(failure_type<U, V> &&v)
{
return static_cast<failure_type<U, V> &&>(v).error();
}
template <class T, class V> constexpr inline T extract_error_from_failure(const failure_type<void, V> & /*unused*/) { return T{}; }
template <class T, class V> constexpr inline T extract_error_from_failure(const failure_type<void, V> & /*unused*/)
{
return T{};
}

template <class T> struct is_basic_result
{
Expand Down Expand Up @@ -355,7 +371,7 @@ class OUTCOME_NODISCARD basic_result : public detail::basic_result_final<R, S, N
template <class... Args>
static constexpr bool enable_inplace_value_error_constructor = //
constructors_enabled //
&&base::template enable_inplace_value_error_constructor<Args...>;
&& base::template enable_inplace_value_error_constructor<Args...>;
template <class... Args> using choose_inplace_value_error_constructor = typename base::template choose_inplace_value_error_constructor<Args...>;
};

Expand Down Expand Up @@ -387,7 +403,7 @@ SIGNATURE NOT RECOGNISED
*/
OUTCOME_TEMPLATE(class Arg, class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(!predicate::constructors_enabled && (sizeof...(Args) >= 0)))
basic_result(Arg && /*unused*/, Args &&... /*unused*/) = delete; // NOLINT basic_result<T, T> is NOT SUPPORTED, see docs!
basic_result(Arg && /*unused*/, Args &&.../*unused*/) = delete; // NOLINT basic_result<T, T> is NOT SUPPORTED, see docs!

/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
Expand Down Expand Up @@ -451,8 +467,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
constexpr explicit basic_result(
const basic_result<T, U, V> &o,
explicit_compatible_copy_conversion_tag /*unused*/ =
explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>)
explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
detail::is_nothrow_constructible<error_type, U>)
: base{typename base::compatible_conversion_tag(), o}
{
no_value_policy_type::on_result_copy_construction(this, o);
Expand All @@ -464,8 +480,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
constexpr explicit basic_result(
basic_result<T, U, V> &&o,
explicit_compatible_move_conversion_tag /*unused*/ =
explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>)
explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
detail::is_nothrow_constructible<error_type, U>)
: base{typename base::compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
{
no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
Expand All @@ -477,8 +493,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
constexpr explicit basic_result(const basic_result<T, U, V> &o,
explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ =
explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_error_code(std::declval<U>())))
explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
noexcept(make_error_code(std::declval<U>())))
: base{typename base::make_error_code_compatible_conversion_tag(), o}
{
no_value_policy_type::on_result_copy_construction(this, o);
Expand All @@ -490,8 +506,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
constexpr explicit basic_result(basic_result<T, U, V> &&o,
explicit_make_error_code_compatible_move_conversion_tag /*unused*/ =
explicit_make_error_code_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_error_code(std::declval<U>())))
explicit_make_error_code_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
noexcept(make_error_code(std::declval<U>())))
: base{typename base::make_error_code_compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
{
no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
Expand All @@ -503,8 +519,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
constexpr explicit basic_result(const basic_result<T, U, V> &o,
explicit_make_exception_ptr_compatible_copy_conversion_tag /*unused*/ =
explicit_make_exception_ptr_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_exception_ptr(std::declval<U>())))
explicit_make_exception_ptr_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
noexcept(make_exception_ptr(std::declval<U>())))
: base{typename base::make_exception_ptr_compatible_conversion_tag(), o}
{
no_value_policy_type::on_result_copy_construction(this, o);
Expand All @@ -516,8 +532,8 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
constexpr explicit basic_result(basic_result<T, U, V> &&o,
explicit_make_exception_ptr_compatible_move_conversion_tag /*unused*/ =
explicit_make_exception_ptr_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_exception_ptr(std::declval<U>())))
explicit_make_exception_ptr_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
noexcept(make_exception_ptr(std::declval<U>())))
: base{typename base::make_exception_ptr_compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
{
no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
Expand All @@ -528,7 +544,7 @@ SIGNATURE NOT RECOGNISED
*/
OUTCOME_TEMPLATE(class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<Args...>))
constexpr explicit basic_result(in_place_type_t<value_type_if_enabled> _, Args &&... args) noexcept(detail::is_nothrow_constructible<value_type, Args...>)
constexpr explicit basic_result(in_place_type_t<value_type_if_enabled> _, Args &&...args) noexcept(detail::is_nothrow_constructible<value_type, Args...>)
: base{_, static_cast<Args &&>(args)...}
{
no_value_policy_type::on_result_in_place_construction(this, in_place_type<value_type>, static_cast<Args &&>(args)...);
Expand All @@ -539,7 +555,7 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TEMPLATE(class U, class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<std::initializer_list<U>, Args...>))
constexpr explicit basic_result(in_place_type_t<value_type_if_enabled> _, std::initializer_list<U> il,
Args &&... args) noexcept(detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
Args &&...args) noexcept(detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
: base{_, il, static_cast<Args &&>(args)...}
{
no_value_policy_type::on_result_in_place_construction(this, in_place_type<value_type>, il, static_cast<Args &&>(args)...);
Expand All @@ -549,7 +565,7 @@ SIGNATURE NOT RECOGNISED
*/
OUTCOME_TEMPLATE(class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<Args...>))
constexpr explicit basic_result(in_place_type_t<error_type_if_enabled> _, Args &&... args) noexcept(detail::is_nothrow_constructible<error_type, Args...>)
constexpr explicit basic_result(in_place_type_t<error_type_if_enabled> _, Args &&...args) noexcept(detail::is_nothrow_constructible<error_type, Args...>)
: base{_, static_cast<Args &&>(args)...}
{
no_value_policy_type::on_result_in_place_construction(this, in_place_type<error_type>, static_cast<Args &&>(args)...);
Expand All @@ -560,7 +576,7 @@ SIGNATURE NOT RECOGNISED
OUTCOME_TEMPLATE(class U, class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<std::initializer_list<U>, Args...>))
constexpr explicit basic_result(in_place_type_t<error_type_if_enabled> _, std::initializer_list<U> il,
Args &&... args) noexcept(detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
Args &&...args) noexcept(detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
: base{_, il, static_cast<Args &&>(args)...}
{
no_value_policy_type::on_result_in_place_construction(this, in_place_type<error_type>, il, static_cast<Args &&>(args)...);
Expand All @@ -570,7 +586,7 @@ SIGNATURE NOT RECOGNISED
*/
OUTCOME_TEMPLATE(class A1, class A2, class... Args)
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_error_constructor<A1, A2, Args...>))
constexpr basic_result(A1 &&a1, A2 &&a2, Args &&... args) noexcept(noexcept(
constexpr basic_result(A1 &&a1, A2 &&a2, Args &&...args) noexcept(noexcept(
typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>(std::declval<A1>(), std::declval<A2>(), std::declval<Args>()...)))
: basic_result(in_place_type<typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>>, static_cast<A1 &&>(a1),
static_cast<A2 &&>(a2), static_cast<Args &&>(args)...)
Expand Down
6 changes: 3 additions & 3 deletions include/outcome/detail/revision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 893c2d0fb8f00b7afe8daf4a6f2782f3d11fc1ae
#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 22:34:16 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 893c2d0f
#define OUTCOME_PREVIOUS_COMMIT_REF 571f9c930e672950e99d5d30f743603aaaf8014c
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-03-13 20:29:49 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 571f9c93
4 changes: 3 additions & 1 deletion include/outcome/experimental/result.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* C interface for result
(C) 2017-2020 Niall Douglas <http://www.nedproductions.biz/> (6 commits)
(C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (6 commits)
File Created: Aug 2017
Expand Down Expand Up @@ -27,6 +27,8 @@ Distributed under the Boost Software License, Version 1.0.

#include <stdint.h> // for intptr_t

#include "../outcome_gdb.h"

#ifdef __cplusplus
extern "C"
{
Expand Down
58 changes: 0 additions & 58 deletions include/outcome/outcome.gdb.py

This file was deleted.

Loading

0 comments on commit c79bd04

Please sign in to comment.