Skip to content

Support to disable formatters for std::optional and std::expected #4457

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

Conversation

robertfalkenberg
Copy link

This MR adds support to disable formatters for std::optional and std::expected, for example, if a custom standard definition is preferred.

The MR follows the same approach as for std::variant in #3716.

To disable these formatters, define the respective macros

#define FMT_CPP_LIB_OPTIONAL 0
#define FMT_CPP_LIB_EXPECTED 0

before loading the fmt library (or via command line to the compiler).

@vitaut
Copy link
Contributor

vitaut commented May 31, 2025

Thanks for the PR but you should only provide formatters for your own types. The macro to disable std::variant formatter is a workaround for old libc++ on macOS and will be removed.

@vitaut vitaut closed this May 31, 2025
@robertfalkenberg
Copy link
Author

Thank you for your time reviewing the MR.

The macro to disable std::variant formatter is a workaround for old libc++ on macOS and will be removed.

OK, I agree - if the plan is to remove those workarounds, then there shouldn't be any extensions towards the opposite direction.

Do you see any other way(s) to provide a project-wide custom version for default std::optional(ANY_TYPE) that does not require

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.

2 participants