{"id":13419746,"url":"https://github.com/fmtlib/fmt","last_synced_at":"2025-12-16T13:59:57.090Z","repository":{"id":5840159,"uuid":"7056202","full_name":"fmtlib/fmt","owner":"fmtlib","description":"A modern formatting library","archived":false,"fork":false,"pushed_at":"2025-12-10T02:27:49.000Z","size":17638,"stargazers_count":23028,"open_issues_count":12,"forks_count":2791,"subscribers_count":316,"default_branch":"master","last_synced_at":"2025-12-14T12:54:07.185Z","etag":null,"topics":["c-plus-plus","chrono","cpp","cross-platform","floating-point","formatting","multiplatform","output","performance","printf","ranges","unicode"],"latest_commit_sha":null,"homepage":"https://fmt.dev","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fmtlib.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/Android.mk","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-12-07T16:26:46.000Z","updated_at":"2025-12-14T09:13:24.000Z","dependencies_parsed_at":"2023-01-14T11:30:42.655Z","dependency_job_id":"cc74bd16-a893-4b4a-bc6f-6a94b722885c","html_url":"https://github.com/fmtlib/fmt","commit_stats":{"total_commits":5963,"total_committers":434,"mean_commits":13.73963133640553,"dds":"0.35887975851081666","last_synced_commit":"f8c9fabd948e4b3caea30d3c281018b0308491bf"},"previous_names":["cppformat/cppformat"],"tags_count":57,"template":false,"template_full_name":null,"purl":"pkg:github/fmtlib/fmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmtlib%2Ffmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmtlib%2Ffmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmtlib%2Ffmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmtlib%2Ffmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fmtlib","download_url":"https://codeload.github.com/fmtlib/fmt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmtlib%2Ffmt/sbom","scorecard":{"id":405525,"data":{"date":"2025-08-17T19:39:49Z","repo":{"name":"github.com/fmtlib/fmt","commit":"72c82296d605ab8b3a415cab0e7c65edccbc7503"},"scorecard":{"version":"v5.2.1","commit":"ab2f6e92482462fe66246d9e32f642855a691dc1"},"score":6.9,"checks":[{"name":"Code-Review","score":3,"reason":"Found 9/28 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#code-review"}},{"name":"Dependency-Update-Tool","score":10,"reason":"update tool detected","details":["Info: detected update tool: Dependabot: .github/dependabot.yml:1"],"documentation":{"short":"Determines if the project uses a dependency update tool.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dependency-update-tool"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#packaging"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/cifuzz.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/doc.yml:6","Info: topLevel 'contents' permission set to 'read': .github/workflows/lint.yml:10","Info: topLevel 'contents' permission set to 'read': .github/workflows/linux.yml:6","Info: topLevel 'contents' permission set to 'read': .github/workflows/macos.yml:6","Info: topLevel permissions set to 'read-all': .github/workflows/scorecard.yml:18","Info: topLevel 'contents' permission set to 'read': .github/workflows/windows.yml:6","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":7,"reason":"dependency not pinned by hash detected -- score normalized to 7","details":["Warn: pipCommand not pinned by hash: .github/workflows/doc.yml:27","Warn: downloadThenRun not pinned by hash: .github/workflows/lint.yml:21","Info:  10 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   4 out of   4 third-party GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#security-policy"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#vulnerabilities"}},{"name":"CII-Best-Practices","score":5,"reason":"badge detected: Passing","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found","Info: CppLibFuzzer integration found: test/fuzzing/chrono-duration.cc:89","Info: CppLibFuzzer integration found: test/fuzzing/chrono-timepoint.cc:26","Info: CppLibFuzzer integration found: test/fuzzing/float.cc:31","Info: CppLibFuzzer integration found: test/fuzzing/main.cc:7","Info: CppLibFuzzer integration found: test/fuzzing/main.cc:20","Info: CppLibFuzzer integration found: test/fuzzing/named-arg.cc:89","Info: CppLibFuzzer integration found: test/fuzzing/one-arg.cc:40","Info: CppLibFuzzer integration found: test/fuzzing/two-args.cc:89","Info: CppLibFuzzer integration found: test/fuzzing/chrono-duration.cc:89","Info: CppLibFuzzer integration found: test/fuzzing/chrono-timepoint.cc:26","Info: CppLibFuzzer integration found: test/fuzzing/float.cc:31","Info: CppLibFuzzer integration found: test/fuzzing/main.cc:7","Info: CppLibFuzzer integration found: test/fuzzing/main.cc:20","Info: CppLibFuzzer integration found: test/fuzzing/named-arg.cc:89","Info: CppLibFuzzer integration found: test/fuzzing/one-arg.cc:40","Info: CppLibFuzzer integration found: test/fuzzing/two-args.cc:89"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#fuzzing"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#sast"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 11.2.0 not signed: https://api.github.com/repos/fmtlib/fmt/releases/216311378","Warn: release artifact 11.1.4 not signed: https://api.github.com/repos/fmtlib/fmt/releases/202621075","Warn: release artifact 11.1.3 not signed: https://api.github.com/repos/fmtlib/fmt/releases/196783379","Warn: release artifact 11.1.2 not signed: https://api.github.com/repos/fmtlib/fmt/releases/194308496","Warn: release artifact 11.1.1 not signed: https://api.github.com/repos/fmtlib/fmt/releases/192494456","Warn: release artifact 11.2.0 does not have provenance: https://api.github.com/repos/fmtlib/fmt/releases/216311378","Warn: release artifact 11.1.4 does not have provenance: https://api.github.com/repos/fmtlib/fmt/releases/202621075","Warn: release artifact 11.1.3 does not have provenance: https://api.github.com/repos/fmtlib/fmt/releases/196783379","Warn: release artifact 11.1.2 does not have provenance: https://api.github.com/repos/fmtlib/fmt/releases/194308496","Warn: release artifact 11.1.1 does not have provenance: https://api.github.com/repos/fmtlib/fmt/releases/192494456"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#signed-releases"}},{"name":"CI-Tests","score":10,"reason":"11 out of 11 merged PRs checked by a CI test -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project runs tests before pull requests are merged.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#ci-tests"}},{"name":"Branch-Protection","score":3,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'master'","Info: 'branch protection settings apply to administrators' is required to merge on branch 'master'","Warn: branch 'master' does not require approvers","Warn: codeowners review is not required on branch 'master'","Warn: no status checks found to merge onto branch 'master'","Warn: PRs are not required to make changes on branch 'master'; or we don't have data to detect it.If you think it might be the latter, make sure to run Scorecard with a PAT or use Repo Rules (that are always public) instead of Branch Protection settings"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#branch-protection"}},{"name":"Contributors","score":10,"reason":"project has 25 contributing companies or organizations","details":["Info: found contributions from: Efficient-Large-Model, EpicGames, Kernel-SU, LSPosed, NVIDIAGameWorks, PixArt-alpha, WiscADSL, Xposed-Modules-Repo, cplusplus, department of mathematics ucsd, fastfetch-cli, googlers, jump trading, llvm, lumicks, maystreet, meta, meta-math, personal work, pybind, sandia national laboratories, sandialabs, simdjson, think-cell, zhejiang university"],"documentation":{"short":"Determines if the project has a set of contributors from multiple organizations (e.g., companies).","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#contributors"}}]},"last_synced_at":"2025-08-18T21:10:00.217Z","repository_id":5840159,"created_at":"2025-08-18T21:10:00.217Z","updated_at":"2025-08-18T21:10:00.217Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27765950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-16T02:00:10.477Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","chrono","cpp","cross-platform","floating-point","formatting","multiplatform","output","performance","printf","ranges","unicode"],"created_at":"2024-07-30T22:01:20.270Z","updated_at":"2025-12-16T13:59:57.075Z","avatar_url":"https://github.com/fmtlib.png","language":"C++","readme":"\u003cimg src=\"https://user-images.githubusercontent.com/576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png\" alt=\"{fmt}\" width=\"25%\"/\u003e\n\n[![image](https://github.com/fmtlib/fmt/workflows/linux/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux)\n[![image](https://github.com/fmtlib/fmt/workflows/macos/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos)\n[![image](https://github.com/fmtlib/fmt/workflows/windows/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows)\n[![fmt is continuously fuzzed at oss-fuzz](https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?\\%0Acolspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\\%0ASummary\u0026q=proj%3Dfmt\u0026can=1)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8880/badge)](https://www.bestpractices.dev/projects/8880)\n[![image](https://api.securityscorecards.dev/projects/github.com/fmtlib/fmt/badge)](https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt)\n[![Ask questions at StackOverflow with the tag fmt](https://img.shields.io/badge/stackoverflow-fmt-blue.svg)](https://stackoverflow.com/questions/tagged/fmt)\n\n**{fmt}** is an open-source formatting library providing a fast and safe\nalternative to C stdio and C++ iostreams.\n\nIf you like this project, please consider donating to one of the funds\nthat help victims of the war in Ukraine: \u003chttps://u24.gov.ua/\u003e.\n\n[Documentation](https://fmt.dev)\n\n[Cheat Sheets](https://hackingcpp.com/cpp/libs/fmt.html)\n\nQ\u0026A: ask questions on [StackOverflow with the tag\nfmt](https://stackoverflow.com/questions/tagged/fmt).\n\nTry {fmt} in [Compiler Explorer](https://godbolt.org/z/8Mx1EW73v).\n\n# Features\n\n- Simple [format API](https://fmt.dev/latest/api/) with positional\n  arguments for localization\n- Implementation of [C++20\n  std::format](https://en.cppreference.com/w/cpp/utility/format) and\n  [C++23 std::print](https://en.cppreference.com/w/cpp/io/print)\n- [Format string syntax](https://fmt.dev/latest/syntax/) similar\n  to Python\\'s\n  [format](https://docs.python.org/3/library/stdtypes.html#str.format)\n- Fast IEEE 754 floating-point formatter with correct rounding,\n  shortness and round-trip guarantees using the\n  [Dragonbox](https://github.com/jk-jeon/dragonbox) algorithm\n- Portable Unicode support\n- Safe [printf\n  implementation](https://fmt.dev/latest/api/#printf-formatting)\n  including the POSIX extension for positional arguments\n- Extensibility: [support for user-defined\n  types](https://fmt.dev/latest/api/#formatting-user-defined-types)\n- High performance: faster than common standard library\n  implementations of `(s)printf`, iostreams, `to_string` and\n  `to_chars`, see [Speed tests](#speed-tests) and [Converting a\n  hundred million integers to strings per\n  second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html)\n- Small code size both in terms of source code with the minimum\n  configuration consisting of just three files, `base.h`, `format.h`\n  and `format-inl.h`, and compiled code; see [Compile time and code\n  bloat](#compile-time-and-code-bloat)\n- Reliability: the library has an extensive set of\n  [tests](https://github.com/fmtlib/fmt/tree/master/test) and is\n  [continuously fuzzed](https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20Summary\u0026q=proj%3Dfmt\u0026can=1)\n- Safety: the library is fully type-safe, errors in format strings can\n  be reported at compile time, automatic memory management prevents\n  buffer overflow errors\n- Ease of use: small self-contained code base, no external\n  dependencies, permissive MIT\n  [license](https://github.com/fmtlib/fmt/blob/master/LICENSE)\n- [Portability](https://fmt.dev/latest/#portability) with\n  consistent output across platforms and support for older compilers\n- Clean warning-free codebase even on high warning levels such as\n  `-Wall -Wextra -pedantic`\n- Locale independence by default\n- Optional header-only configuration enabled with the\n  `FMT_HEADER_ONLY` macro\n\nSee the [documentation](https://fmt.dev) for more details.\n\n# Examples\n\n**Print to stdout** ([run](https://godbolt.org/z/Tevcjh))\n\n``` c++\n#include \u003cfmt/base.h\u003e\n\nint main() {\n  fmt::print(\"Hello, world!\\n\");\n}\n```\n\n**Format a string** ([run](https://godbolt.org/z/oK8h33))\n\n``` c++\nstd::string s = fmt::format(\"The answer is {}.\", 42);\n// s == \"The answer is 42.\"\n```\n\n**Format a string using positional arguments**\n([run](https://godbolt.org/z/Yn7Txe))\n\n``` c++\nstd::string s = fmt::format(\"I'd rather be {1} than {0}.\", \"right\", \"happy\");\n// s == \"I'd rather be happy than right.\"\n```\n\n**Print dates and times** ([run](https://godbolt.org/z/c31ExdY3W))\n\n``` c++\n#include \u003cfmt/chrono.h\u003e\n\nint main() {\n  auto now = std::chrono::system_clock::now();\n  fmt::print(\"Date and time: {}\\n\", now);\n  fmt::print(\"Time: {:%H:%M}\\n\", now);\n}\n```\n\nOutput:\n\n    Date and time: 2023-12-26 19:10:31.557195597\n    Time: 19:10\n\n**Print a container** ([run](https://godbolt.org/z/MxM1YqjE7))\n\n``` c++\n#include \u003cvector\u003e\n#include \u003cfmt/ranges.h\u003e\n\nint main() {\n  std::vector\u003cint\u003e v = {1, 2, 3};\n  fmt::print(\"{}\\n\", v);\n}\n```\n\nOutput:\n\n    [1, 2, 3]\n\n**Check a format string at compile time**\n\n``` c++\nstd::string s = fmt::format(\"{:d}\", \"I am not a number\");\n```\n\nThis gives a compile-time error in C++20 because `d` is an invalid\nformat specifier for a string.\n\n**Write a file from a single thread**\n\n``` c++\n#include \u003cfmt/os.h\u003e\n\nint main() {\n  auto out = fmt::output_file(\"guide.txt\");\n  out.print(\"Don't {}\", \"Panic\");\n}\n```\n\nThis can be [up to 9 times faster than `fprintf`](\nhttp://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html).\n\n**Print with colors and text styles**\n\n``` c++\n#include \u003cfmt/color.h\u003e\n\nint main() {\n  fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,\n             \"Hello, {}!\\n\", \"world\");\n  fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |\n             fmt::emphasis::underline, \"Olá, {}!\\n\", \"Mundo\");\n  fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,\n             \"你好{}！\\n\", \"世界\");\n}\n```\n\nOutput on a modern terminal with Unicode support:\n\n![image](https://github.com/fmtlib/fmt/assets/%0A576385/2a93c904-d6fa-4aa6-b453-2618e1c327d7)\n\n# Benchmarks\n\n## Speed tests\n\n| Library           | Method        | Run Time, s |\n|-------------------|---------------|-------------|\n| libc              | printf        |   0.66      |\n| libc++            | std::ostream  |   1.63      |\n| {fmt} 12.1        | fmt::print    |   0.44      |\n| Boost Format 1.88 | boost::format |   3.89      |\n| Folly Format      | folly::format |   1.28      |\n\n{fmt} is the fastest of the benchmarked methods, \\~50% faster than\n`printf`.\n\nThe above results were generated by building `tinyformat_test.cpp` on\nmacOS 15.6.1 with `clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT`, and\ntaking the best of three runs. In the test, the format string\n`\"%0.10f:%04d:%+g:%s:%p:%c:%%\\n\"` or equivalent is filled 2,000,000\ntimes with output sent to `/dev/null`; for further details refer to the\n[source](https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc).\n\n{fmt} is up to 20-30x faster than `std::ostringstream` and `sprintf` on\nIEEE754 `float` and `double` formatting\n([dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark)) and faster\nthan [double-conversion](https://github.com/google/double-conversion)\nand [ryu](https://github.com/ulfjack/ryu):\n\n[![image](https://user-images.githubusercontent.com/576385/95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png)](https://fmt.dev/unknown_mac64_clang12.0.html)\n\n## Compile time and code bloat\n\nThe script [bloat-test.py][test] from [format-benchmark][bench] tests compile\ntime and code bloat for nontrivial projects. It generates 100 translation units\nand uses `printf()` or its alternative five times in each to simulate a\nmedium-sized project. The resulting executable size and compile time (Apple\nclang version 15.0.0 (clang-1500.1.0.2.5), macOS Sonoma, best of three) is shown\nin the following tables.\n\n[test]: https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py\n[bench]: https://github.com/fmtlib/format-benchmark\n\n**Optimized build (-O3)**\n\n| Method          | Compile Time, s | Executable size, KiB | Stripped size, KiB |\n|-----------------|-----------------|----------------------|--------------------|\n| printf          |             1.6 |                   54 |                 50 |\n| IOStreams       |            28.4 |                   98 |                 84 |\n| {fmt} `1122268` |             5.0 |                   54 |                 50 |\n| tinyformat      |            32.6 |                  164 |                136 |\n| Boost Format    |            55.0 |                  530 |                317 |\n\n{fmt} is fast to compile and is comparable to `printf` in terms of per-call\nbinary size (within a rounding error on this system).\n\n**Non-optimized build**\n\n| Method          | Compile Time, s | Executable size, KiB | Stripped size, KiB |\n|-----------------|-----------------|----------------------|--------------------|\n| printf          |             1.4 |                   54 |                 50 |\n| IOStreams       |            27.0 |                   88 |                 68 |\n| {fmt} `1122268` |             4.7 |                   87 |                 84 |\n| tinyformat      |            28.1 |                  185 |                145 |\n| Boost Format    |            38.9 |                  678 |                381 |\n\n`libc`, `lib(std)c++`, and `libfmt` are all linked as shared libraries\nto compare formatting function overhead only. Boost Format is a\nheader-only library so it doesn\\'t provide any linkage options.\n\n## Running the tests\n\nPlease refer to [Building the\nlibrary](https://fmt.dev/latest/get-started/#building-from-source) for\ninstructions on how to build the library and run the unit tests.\n\nBenchmarks reside in a separate repository,\n[format-benchmarks](https://github.com/fmtlib/format-benchmark), so to\nrun the benchmarks you first need to clone this repository and generate\nMakefiles with CMake:\n\n    $ git clone --recursive https://github.com/fmtlib/format-benchmark.git\n    $ cd format-benchmark\n    $ cmake .\n\nThen you can run the speed test:\n\n    $ make speed-test\n\nor the bloat test:\n\n    $ make bloat-test\n\n# Migrating code\n\n[clang-tidy](https://clang.llvm.org/extra/clang-tidy/) v18 provides the\n[modernize-use-std-print](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-print.html)\ncheck that is capable of converting occurrences of `printf` and\n`fprintf` to `fmt::print` if configured to do so. (By default it\nconverts to `std::print`.)\n\n# Notable projects using this library\n\n- [0 A.D.](https://play0ad.com/): a free, open-source, cross-platform\n  real-time strategy game\n- [AMPL/MP](https://github.com/ampl/mp): an open-source library for\n  mathematical programming\n- [Apple's FoundationDB](https://github.com/apple/foundationdb): an open-source,\n  distributed, transactional key-value store\n- [Aseprite](https://github.com/aseprite/aseprite): animated sprite\n  editor \u0026 pixel art tool\n- [AvioBook](https://www.aviobook.aero/en): a comprehensive aircraft\n  operations suite\n- [Blizzard Battle.net](https://battle.net/): an online gaming\n  platform\n- [Celestia](https://celestia.space/): real-time 3D visualization of\n  space\n- [Ceph](https://ceph.com/): a scalable distributed storage system\n- [ccache](https://ccache.dev/): a compiler cache\n- [ClickHouse](https://github.com/ClickHouse/ClickHouse): an\n  analytical database management system\n- [ContextVision](https://www.contextvision.com/): medical imaging software\n- [Contour](https://github.com/contour-terminal/contour/): a modern\n  terminal emulator\n- [CUAUV](https://cuauv.org/): Cornell University\\'s autonomous\n  underwater vehicle\n- [Drake](https://drake.mit.edu/): a planning, control, and analysis\n  toolbox for nonlinear dynamical systems (MIT)\n- [Envoy](https://github.com/envoyproxy/envoy): C++ L7 proxy and\n  communication bus (Lyft)\n- [FiveM](https://fivem.net/): a modification framework for GTA V\n- [fmtlog](https://github.com/MengRao/fmtlog): a performant\n  fmtlib-style logging library with latency in nanoseconds\n- [Folly](https://github.com/facebook/folly): Facebook open-source\n  library\n- [GemRB](https://gemrb.org/): a portable open-source implementation\n  of Bioware's Infinity Engine\n- [Grand Mountain\n  Adventure](https://store.steampowered.com/app/1247360/Grand_Mountain_Adventure/):\n  a beautiful open-world ski \u0026 snowboarding game\n- [HarpyWar/pvpgn](https://github.com/pvpgn/pvpgn-server): Player vs\n  Player Gaming Network with tweaks\n- [KBEngine](https://github.com/kbengine/kbengine): an open-source\n  MMOG server engine\n- [Keypirinha](https://keypirinha.com/): a semantic launcher for\n  Windows\n- [Kodi](https://kodi.tv/) (formerly xbmc): home theater software\n- [Knuth](https://kth.cash/): high-performance Bitcoin full-node\n- [libunicode](https://github.com/contour-terminal/libunicode/): a\n  modern C++17 Unicode library\n- [MariaDB](https://mariadb.org/): relational database management\n  system\n- [Microsoft Verona](https://github.com/microsoft/verona): research\n  programming language for concurrent ownership\n- [MongoDB](https://mongodb.com/): distributed document database\n- [MongoDB Smasher](https://github.com/duckie/mongo_smasher): a small\n  tool to generate randomized datasets\n- [OpenSpace](https://openspaceproject.com/): an open-source\n  astrovisualization framework\n- [PenUltima Online (POL)](https://www.polserver.com/): an MMO server,\n  compatible with most Ultima Online clients\n- [PyTorch](https://github.com/pytorch/pytorch): an open-source\n  machine learning library\n- [quasardb](https://www.quasardb.net/): a distributed,\n  high-performance, associative database\n- [Quill](https://github.com/odygrd/quill): asynchronous low-latency\n  logging library\n- [QKW](https://github.com/ravijanjam/qkw): generalizing aliasing to\n  simplify navigation, and execute complex multi-line terminal\n  command sequences\n- [redis-cerberus](https://github.com/HunanTV/redis-cerberus): a Redis\n  cluster proxy\n- [redpanda](https://vectorized.io/redpanda): a 10x faster Kafka®\n  replacement for mission-critical systems written in C++\n- [rpclib](http://rpclib.net/): a modern C++ msgpack-RPC server and\n  client library\n- [Salesforce Analytics\n  Cloud](https://www.salesforce.com/analytics-cloud/overview/):\n  business intelligence software\n- [Scylla](https://www.scylladb.com/): a Cassandra-compatible NoSQL\n  data store that can handle 1 million transactions per second on a\n  single server\n- [Seastar](http://www.seastar-project.org/): an advanced, open-source\n  C++ framework for high-performance server applications on modern\n  hardware\n- [spdlog](https://github.com/gabime/spdlog): super fast C++ logging\n  library\n- [Stellar](https://www.stellar.org/): financial platform\n- [Touch Surgery](https://www.touchsurgery.com/): surgery simulator\n- [TrinityCore](https://github.com/TrinityCore/TrinityCore):\n  open-source MMORPG framework\n- [🐙 userver framework](https://userver.tech/): open-source\n  asynchronous framework with a rich set of abstractions and database\n  drivers\n- [Windows Terminal](https://github.com/microsoft/terminal): the new\n  Windows terminal\n\n[More\\...](https://github.com/search?q=fmtlib\u0026type=Code)\n\nIf you are aware of other projects using this library, please let me\nknow by [email](mailto:victor.zverovich@gmail.com) or by submitting an\n[issue](https://github.com/fmtlib/fmt/issues).\n\n# Motivation\n\nSo why yet another formatting library?\n\nThere are plenty of methods for doing this task, from standard ones like\nthe printf family of function and iostreams to Boost Format and\nFastFormat libraries. The reason for creating a new library is that\nevery existing solution that I found either had serious issues or\ndidn\\'t provide all the features I needed.\n\n## printf\n\nThe good thing about `printf` is that it is pretty fast and readily\navailable being a part of the C standard library. The main drawback is\nthat it doesn\\'t support user-defined types. `printf` also has safety\nissues although they are somewhat mitigated with [\\_\\_attribute\\_\\_\n((format (printf,\n\\...))](https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html) in\nGCC. There is a POSIX extension that adds positional arguments required\nfor\n[i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization)\nto `printf` but it is not a part of C99 and may not be available on some\nplatforms.\n\n## iostreams\n\nThe main issue with iostreams is best illustrated with an example:\n\n``` c++\nstd::cout \u003c\u003c std::setprecision(2) \u003c\u003c std::fixed \u003c\u003c 1.23456 \u003c\u003c \"\\n\";\n```\n\nwhich is a lot of typing compared to printf:\n\n``` c++\nprintf(\"%.2f\\n\", 1.23456);\n```\n\nMatthew Wilson, the author of FastFormat, called this \\\"chevron hell\\\".\niostreams don\\'t support positional arguments by design.\n\nThe good part is that iostreams support user-defined types and are safe\nalthough error handling is awkward.\n\n## Boost Format\n\nThis is a very powerful library that supports both `printf`-like format\nstrings and positional arguments. Its main drawback is performance.\nAccording to various benchmarks, it is much slower than other methods\nconsidered here. Boost Format also has excessive build times and severe\ncode bloat issues (see [Benchmarks](#benchmarks)).\n\n## FastFormat\n\nThis is an interesting library that is fast, safe and has positional\narguments. However, it has significant limitations, citing its author:\n\n\u003e Three features that have no hope of being accommodated within the\n\u003e current design are:\n\u003e\n\u003e - Leading zeros (or any other non-space padding)\n\u003e - Octal/hexadecimal encoding\n\u003e - Runtime width/alignment specification\n\nIt is also quite big and has a heavy dependency, on STLSoft, which might be\ntoo restrictive for use in some projects.\n\n## Boost Spirit.Karma\n\nThis is not a formatting library but I decided to include it here for\ncompleteness. As iostreams, it suffers from the problem of mixing\nverbatim text with arguments. The library is pretty fast, but slower on\ninteger formatting than `fmt::format_to` with format string compilation\non Karma\\'s own benchmark, see [Converting a hundred million integers to\nstrings per\nsecond](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html).\n\n# License\n\n{fmt} is distributed under the MIT\n[license](https://github.com/fmtlib/fmt/blob/master/LICENSE).\n\n# Documentation License\n\nThe [Format String Syntax](https://fmt.dev/latest/syntax/) section\nin the documentation is based on the one from Python [string module\ndocumentation](https://docs.python.org/3/library/string.html#module-string).\nFor this reason, the documentation is distributed under the Python\nSoftware Foundation license available in\n[doc/python-license.txt](https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt).\nIt only applies if you distribute the documentation of {fmt}.\n\n# Maintainers\n\nThe {fmt} library is maintained by Victor Zverovich\n([vitaut](https://github.com/vitaut)) with contributions from many other\npeople. See\n[Contributors](https://github.com/fmtlib/fmt/graphs/contributors) and\n[Releases](https://github.com/fmtlib/fmt/releases) for some of the\nnames. Let us know if your contribution is not listed or mentioned\nincorrectly and we\\'ll make it right.\n\n# Security Policy\n\nTo report a security issue, please disclose it at [security\nadvisory](https://github.com/fmtlib/fmt/security/advisories/new).\n\nThis project is maintained by a team of volunteers on a\nreasonable-effort basis. As such, please give us at least *90* days to\nwork on a fix before public exposure.\n","funding_links":[],"categories":["C++","TODO scan for Android support in followings","Miscellaneous","HarmonyOS","Containers \u0026 Language Extentions \u0026 Linting","C++ Libraries","C/C++ 程序设计","Repos","Formatting","排序","Libraries \u0026 Frameworks:","Data Formatting and Presentation","Text Handling","User Interface","Severals"],"sub_categories":["Windows Manager","For C++/C","Tokenizer","网络服务_其他","多项混杂","Other","printf","RPC (_Remote Procedure Call_)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmtlib%2Ffmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffmtlib%2Ffmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmtlib%2Ffmt/lists"}