{"id":13677698,"url":"https://github.com/mpusz/mp-units","last_synced_at":"2025-12-24T22:14:14.718Z","repository":{"id":33619246,"uuid":"145692046","full_name":"mpusz/mp-units","owner":"mpusz","description":"The quantities and units library for C++","archived":false,"fork":false,"pushed_at":"2025-04-04T11:27:56.000Z","size":37695,"stargazers_count":1172,"open_issues_count":62,"forks_count":100,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-11T16:19:13.527Z","etag":null,"topics":["cmake","conan","cpp","cpp20","cpp23","dimensional-analysis","dimensions","isq","library","physical-quantities","physical-units","quantity","quantity-manipulation","safety","si","system-of-quantities","system-of-units","units","units-of-measure","units-of-measurement"],"latest_commit_sha":null,"homepage":"https://mpusz.github.io/mp-units/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpusz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-22T10:12:46.000Z","updated_at":"2025-04-05T21:27:28.000Z","dependencies_parsed_at":"2024-01-06T12:54:32.211Z","dependency_job_id":"253b6573-cffc-4231-a6c2-9fe953b9fac0","html_url":"https://github.com/mpusz/mp-units","commit_stats":{"total_commits":3427,"total_committers":38,"mean_commits":90.1842105263158,"dds":"0.15757222060110887","last_synced_commit":"4492d42b9117b170f583f4ee4317c95fc988fd44"},"previous_names":["mpusz/units"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpusz%2Fmp-units","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpusz%2Fmp-units/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpusz%2Fmp-units/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpusz%2Fmp-units/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpusz","download_url":"https://codeload.github.com/mpusz/mp-units/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480434,"owners_count":21110937,"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","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":["cmake","conan","cpp","cpp20","cpp23","dimensional-analysis","dimensions","isq","library","physical-quantities","physical-units","quantity","quantity-manipulation","safety","si","system-of-quantities","system-of-units","units","units-of-measure","units-of-measurement"],"created_at":"2024-08-02T13:00:45.945Z","updated_at":"2025-12-24T22:14:14.710Z","avatar_url":"https://github.com/mpusz.png","language":"C++","readme":"\u003c!-- markdownlint-disable MD041 --\u003e\n\u003c!-- markdownlint-disable-next-line MD033 --\u003e\n\u003cimg align=\"right\" height=135px src=\"docs/assets/images/mp-units-color.svg\" alt=\"logo\"\u003e\n\n[![License](https://img.shields.io/github/license/mpusz/mp-units?cacheSeconds=3600\u0026color=informational\u0026label=License)](./LICENSE.md)\n[![C++ Standard](https://img.shields.io/badge/C%2B%2B-20%2F23-blue)](https://en.cppreference.com/w/cpp/compiler_support#cpp20)\n\n[![Conan CI](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/ci-conan.yml?branch=master\u0026label=Conan%20CI)](https://github.com/mpusz/mp-units/actions/workflows/ci-conan.yml)\n[![CMake CI](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/ci-test-package-cmake.yml?branch=master\u0026label=CMake%20CI)](https://github.com/mpusz/mp-units/actions/workflows/ci-test-package-cmake.yml)\n[![clang-tidy CI](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/ci-clang-tidy.yml?branch=master\u0026label=clang-tidy%20CI)](https://github.com/mpusz/mp-units/actions/workflows/ci-clang-tidy.yml)\n[![Freestanding CI](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/ci-freestanding.yml?branch=master\u0026label=Freestanding%20CI)](https://github.com/mpusz/mp-units/actions/workflows/ci-freestanding.yml)\n[![Formatting CI](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/ci-formatting.yml?branch=master\u0026label=Formatting%20CI)](https://github.com/mpusz/mp-units/actions/workflows/ci-formatting.yml)\n[![Documentation](https://img.shields.io/github/actions/workflow/status/mpusz/mp-units/documentation.yml?branch=master\u0026label=Documentation)](https://github.com/mpusz/mp-units/actions?query=workflow%3ADocumentation+branch%3Amaster)\n\n[![Conan Center](https://img.shields.io/conan/v/mp-units?label=ConanCenter\u0026color=blue)](https://conan.io/center/mp-units)\n[![Conan testing](https://img.shields.io/badge/mpusz.jfrog.io-2.5.0%3Atesting-blue)](https://mpusz.jfrog.io/ui/packages/conan:%2F%2Fmp-units/2.5.0)\n\n\n# `mp-units` – The Quantities and Units Library for C++\n\n\u003e 🚀 **ISO C++29 Standardization Candidate** – The future of dimensional analysis in C++!\n\n**The `mp-units` library is a candidate for ISO standardization for C++29.**\nMore context can be found in the following ISO C++ proposals:\n\n- [P1935: A C++ Approach to Physical Units](https://wg21.link/p1935)\n- [P2980: A motivation, scope, and plan for a quantities and units library](https://wg21.link/p2980)\n- [P3045: Quantities and units library](https://wg21.link/p3045)\n\n\u003e 🤝 **We are actively seeking organizations and individuals interested in**\n\u003e **field‑trialing the library!**\n\n\n## 🌟 Share Your Success Story\n\n**Help shape the future of C++!**\nYour testimonials help **demonstrate real-world value** to the ISO C++ Committee and\nother potential library users!\n\nWhether you're using mp-units in **production**, **research**, or **education**:\n\n- **Organizations**: Share your production deployments and success stories\n- **Academics**: Report research applications and teaching experiences\n- **Developers**: Tell us about your innovative use cases and benefits\n\n[![Share Experience](https://img.shields.io/badge/Share_Your-Usage_Experience-blue?style=for-the-badge\u0026labelColor=black\u0026label=🌟%20Share%20Your)](https://github.com/mpusz/mp-units/issues/new?template=usage_experience.yml)\n\n\n## 📚 Documentation\n\nExtensive project documentation is available on the **[project site](https://mpusz.github.io/mp-units)**.\nIt includes:\n\n- **Installation instructions** – Get up and running quickly\n- **Detailed user's guide** – Comprehensive usage documentation\n- **Design rationale** – Understanding the architectural decisions\n- **API reference** – Complete technical documentation\n- **Tutorials** – Step-by-step learning resources\n- **Examples** – Real-world usage demonstrations\n\n\n## ⚡ TL;DR\n\n**`mp-units`** is a Modern C++ (C++20 and later) library providing compile‑time\ndimensional analysis and safe manipulation of units, quantities, and quantity points.\n\n### Key Features\n\n- **Type Safety** – Strongly typed quantities, units, dimensions, and quantity points\n- **Zero Runtime Cost** – Compile‑time dimensional analysis with no runtime overhead\n- **Unified Design** – Comprehensive model for units, dimensions, quantities, and point origins\n- **Rich Text Formatting** – Text formatting support with extensive options \u0026\n  character sets\n- **Flexible Usage** – C++ modules support (when available) and header‑only usage\n- **Configurable** – Contracts, freestanding mode, and natural units (experimental)\n- **Interoperable** – Seamless pathways for legacy and external libraries\n\n### Quick Example\n\nHere's a taste of what **mp-units** can do:\n\n```cpp\n#include \u003cmp-units/systems/si.h\u003e\n\nusing namespace mp_units;\nusing namespace mp_units::si::unit_symbols;\n\n// simple numeric operations\nstatic_assert(10 * km / 2 == 5 * km);\n\n// conversions to common units\nstatic_assert(1 * h == 3600 * s);\nstatic_assert(1 * km + 1 * m == 1001 * m);\n\n// derived quantities\nstatic_assert(1 * km / (1 * s) == 1000 * m / s);\nstatic_assert(2 * km / h * (2 * h) == 4 * km);\nstatic_assert(2 * km / (2 * km / h) == 1 * h);\n\nstatic_assert(2 * m * (3 * m) == 6 * m2);\n\nstatic_assert(10 * km / (5 * km) == 2 * one);\n\nstatic_assert(1000 / (1 * s) == 1 * kHz);\n```\n\n[![Try it live on Compiler Explorer](https://img.shields.io/badge/Try_live_on-Compiler_Explorer-black?style=for-the-badge\u0026logo=compilerexplorer\u0026labelColor=black\u0026color=67C52A)](https://godbolt.org/z/fT1r4sohs)\n\n### Modern C++ Design\n\nThe library makes extensive use of **C++20 features** (concepts, class types as NTTPs, etc.).\nThis enables powerful yet easy‑to‑use interfaces while performing all conversions and dimensional\nanalysis at compile time—without sacrificing runtime performance or accuracy.\n\n### More Advanced Example\n\nHere's a broader preview showcasing **mp-units** capabilities:\n\n```cpp\n#include \u003cmp-units/systems/international.h\u003e\n#include \u003cmp-units/systems/isq.h\u003e\n#include \u003cmp-units/systems/si.h\u003e\n#include \u003cformat\u003e\n#include \u003ciomanip\u003e\n#include \u003ciostream\u003e\n#include \u003cprint\u003e\n\nusing namespace mp_units;\n\nconstexpr QuantityOf\u003cisq::speed\u003e auto avg_speed(QuantityOf\u003cisq::length\u003e auto d,\n                                                QuantityOf\u003cisq::time\u003e auto t)\n{\n  return d / t;\n}\n\nint main()\n{\n  using namespace mp_units::si::unit_symbols;\n  using namespace mp_units::international::unit_symbols;\n\n  constexpr quantity v1 = 110 * km / h;\n  constexpr quantity v2 = 70 * mph;\n  constexpr quantity v3 = avg_speed(220. * isq::distance[km], 2 * h);\n  constexpr quantity v4 = avg_speed(isq::distance(140. * mi), 2 * h);\n  constexpr quantity v5 = v3.in(m / s);\n  constexpr quantity v6 = value_cast\u003cm / s\u003e(v4);\n  constexpr quantity v7 = value_cast\u003cint\u003e(v6);\n\n  std::cout \u003c\u003c v1 \u003c\u003c '\\n';                                        // 110 km/h\n  std::cout \u003c\u003c std::setw(10) \u003c\u003c std::setfill('*') \u003c\u003c v2 \u003c\u003c '\\n';  // ***70 mi/h\n  std::cout \u003c\u003c std::format(\"{:*^10}\\n\", v3);                      // *110 km/h*\n  std::println(\"{:%N in %U of %D}\", v4);                          // 70 in mi/h of LT⁻¹\n  std::println(\"{::N[.2f]}\", v5);                                 // 30.56 m/s\n  std::println(\"{::N[.2f]U[dn]}\", v6);                            // 31.29 m⋅s⁻¹\n  std::println(\"{:%N}\", v7);                                      // 31\n}\n```\n\n[![Try it live on Compiler Explorer](https://img.shields.io/badge/Try_live_on-Compiler_Explorer-black?style=for-the-badge\u0026logo=compilerexplorer\u0026labelColor=black\u0026color=67C52A)](https://godbolt.org/z/fxcjs19ah)\n\n\n## 🔍 Try It Out\n\n### Compiler Explorer\n\n**mp-units** is available on Compiler Explorer for instant experimentation!\nPerfect for fast, zero‑setup trials and prototyping your ideas.\n\n\n### GitHub Codespaces\n\nFor **advanced development** or **contributions**, we provide a fully configured cloud\ndevelopment environment with [GitHub Codespaces](https://docs.github.com/en/codespaces):\n\n[![Open in GitHub Codespaces](https://img.shields.io/badge/Open_in-GitHub_Codespaces-blue?style=for-the-badge\u0026logo=github\u0026labelColor=black\u0026color=2088FF)](https://codespaces.new/mpusz/mp-units)\n\n**Alternatives:**\n1. Navigate to the repository → **\"Code\"** → **\"Codespaces\"** → **\"Create codespace on master\"**\n2. Use the pre‑configured devcontainer and Docker image manually in your IDE\n\nFor detailed environment documentation, see [`.devcontainer/README.md`](.devcontainer/README.md).\n\n### Install as a Dependency\n\n🥇 **Recommended:** We recommend using [**Conan**](https://conan.io/center/recipes/mp-units)\nto integrate **mp-units** with your project.\n\n**Multiple options available!** Please refer to our comprehensive\n[**Installation and Usage Guide**](https://mpusz.github.io/mp-units/latest/getting_started/installation_and_usage)\nfor all supported integration methods.\n\n\n## 🤝 Contributors\n\n**mp-units** is made possible by our amazing community of contributors! 💪\n\n[![Contributors](https://img.shields.io/github/contributors/mpusz/mp-units?style=for-the-badge\u0026logo=github\u0026labelColor=black\u0026color=blue)](https://github.com/mpusz/mp-units/graphs/contributors)\n[![Commits](https://img.shields.io/github/commit-activity/m/mpusz/mp-units?style=for-the-badge\u0026logo=git\u0026labelColor=black\u0026color=green)](https://github.com/mpusz/mp-units/pulse)\n[![Stars](https://img.shields.io/github/stars/mpusz/mp-units?style=for-the-badge\u0026label=⭐%20Stars\u0026labelColor=black\u0026color=gold)](https://github.com/mpusz/mp-units/stargazers)\n\n### 🏆 Core Team\n\n- **[Mateusz Pusz](https://github.com/mpusz)** – Project founder and lead\n- **[Johel Ernesto Guerrero Peña](https://github.com/JohelEGP)** – Core maintainer\n- **[Chip Hogg](https://github.com/chiphogg)** – Core maintainer\n\n### 🙏 All Contributors\n\nWe appreciate **every contribution**, from code to documentation to community support!\n\n🌟 See our [**Contributors Page**](CONTRIBUTORS.md) for the complete list and recognition details.\n\n\u003e **Ready to contribute?** Check out our\n[**Contributing Guide**](https://mpusz.github.io/mp-units/latest/getting_started/contributing/)\nto get started! 🚀\n\n\n## 💝 Support the Project\n\n**mp-units** is developed as open source with the ambitious goal of C++29 standardization.\nYour support helps maintain development momentum and accelerate standardization efforts!\n\n**Ways to support:**\n- ⭐ **Star the repository** – Show your appreciation and help others discover **mp-units**\n- 💰 **Become a sponsor** – Financial support enables continued development\n- 📢 **Share your success story** – Help demonstrate real-world value for standardization\n  and other potential users\n- 🤝 **Contribute** – Code, documentation, feedback, and community support\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpusz%2Fmp-units","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpusz%2Fmp-units","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpusz%2Fmp-units/lists"}