Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added formatter for std::expected #3834

Merged
merged 5 commits into from
Feb 3, 2024
Merged

Conversation

dominicpoeschko
Copy link
Contributor

Simple implementation of a 'std::expected' formatter.
Open for discussions :)

By submitting this pull request, you agree to license your contribution(s)
under the terms outlined in LICENSE.rst and represent that you have the right
to do so.

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

include/fmt/std.h Outdated Show resolved Hide resolved
include/fmt/std.h Outdated Show resolved Hide resolved
@vitaut vitaut merged commit e5bab8d into fmtlib:master Feb 3, 2024
41 checks passed
@vitaut
Copy link
Contributor

vitaut commented Feb 3, 2024

Merged, thanks!

happymonkey1 pushed a commit to happymonkey1/fmt that referenced this pull request Apr 7, 2024

if (value.has_value()) {
out = detail::write<Char>(out, "expected(");
out = detail::write_escaped_alternative<Char>(out, value.value());
Copy link

@CJCombrink CJCombrink Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't *value be a better call here?
Given that it was confirmed that value has_value() there should be no need for the 'checked retrieval' of the value?
see std::expected<T,E>::operator*

out = detail::write_escaped_alternative<Char>(out, *value);

(edit) I know this is after the fact, I am just working through the release notes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, a PR to change this to use dereference would be welcome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: #4040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants