[PR #5336] Import fmtlib/fmt@6.2.0, a C++20-style format library #26264

Closed
opened 2026-01-31 09:15:00 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/5336

State: closed
Merged: Yes


We received a request from our localization team to switch from
printf-style format strings (%s, %u) to format strings with positional
argument support. I've been hoping for a long time to take a dependency
on C++20's std::format, but we're just not somewhere we can do that.
Enter fmt. fmt is exactly the library we need.

Minor comparison:

then

std::wstring_view world = /* ... */;
auto str{ wil::str_printf<std::wstring>(L"hello %.*s",
	   gsl::narrow_cast<size_t>(world.size()),
	   world.data()) };

now

auto str{ fmt::format(L"hello {0}", world) };

If you really want to use the print specifiers:

auto str{ fmt::printf(L"hello %s", world) };

It's got optional compile-time checking for format strings and is
MIT-licensed. Eventually, we should be able to replace fmt:: with std::
and end up pretty much where we left off.
What more could you ask for?

It has a header-only mode, but it seemed easier on the compiler (and the
linker) to throw together a quick static library project that produces
the source-level components of fmt.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/5336 **State:** closed **Merged:** Yes --- We received a request from our localization team to switch from printf-style format strings (%s, %u) to format strings with positional argument support. I've been hoping for a long time to take a dependency on C++20's std::format, but we're just not somewhere we can do that. Enter fmt. fmt is _exactly_ the library we need. Minor comparison: ### then ```c++ std::wstring_view world = /* ... */; auto str{ wil::str_printf<std::wstring>(L"hello %.*s", gsl::narrow_cast<size_t>(world.size()), world.data()) }; ``` ### now ```c++ auto str{ fmt::format(L"hello {0}", world) }; ``` If you really want to use the print specifiers: ``` auto str{ fmt::printf(L"hello %s", world) }; ``` It's got optional compile-time checking for format strings and is MIT-licensed. Eventually, we should be able to replace fmt:: with std:: and end up pretty much where we left off. What more could you ask for? It has a header-only mode, but it seemed easier on the compiler (and the linker) to throw together a quick static library project that produces the source-level components of fmt.
claunia added the pull-request label 2026-01-31 09:15:00 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26264