[libcxx-commits] [libcxx] [libc++] Replace `std::optional` in `__format/format_context.h` with a re-implementation (PR #148876)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 15 09:44:32 PDT 2025


ldionne wrote:

IMO, what we should do is granularize `<optional>`:

- `<__optional/optional.h>` contains the definition for `std::optional`
- `<__optional/format.h>` contains the formatting-related stuff for `std::optional`
- `<optional>` includes both

Then, from most places where we don't need `std::format` support, we'd just include `<__optional/optional.h>`. End-users would (obviously) include `<optional>` and they'd get everything they need.

I think that would break the cycle you encounter above because now `__format/format_context.h` would include `<__optional/optional.h>`, which doesn't try to re-include formatters. What do you think?

https://github.com/llvm/llvm-project/pull/148876


More information about the libcxx-commits mailing list