Files
mp-units/docs/getting_started/about.md
2026-01-29 17:32:18 +01:00

6.0 KiB
Raw Blame History

About mp-units

mp-units is a modern C++ library for compiletime dimensional analysis and unit/quantity manipulation. The earliest versions were inspired by std::chrono::duration, but with each release the interfaces intentionally diverged to provide a better user experience.

!!! info

A brief introduction to the library's interfaces and the rationale for
changes in version 2.0 of **mp-units** were provided in detail by
[Mateusz Pusz](https://github.com/mpusz) in the
["The Power of C++ Templates With mp-units: Lessons Learned & a New
Library Design" talk at the C++ on Sea 2023
conference](https://www.youtube.com/watch?v=eUdz0WvOMm0).

Open Source

mp-units is Free and Open Source under the permissive MIT license. Browse the source, ask questions, report bugs, or suggest improvements at https://github.com/mpusz/mp-units.

With the User's Experience in Mind

Most key design decisions aim to deliver the best possible user experience. Many other C++ physicalunits libraries are "famous" for enormous, hardtodigest error messages. mp-units strives to invert that reputation: making compiletime errors concise, readable, and actionable.

To achieve this goal, several techniques are applied:

!!! important "Important: It is all about errors"

In many generic C++ libraries, compile-time errors do not happen often. It is hard to
break `std::string` or `std::vector` in a way that won't compile with a huge error
log. Physical quantities and units libraries are different.
**Generation of compile-time errors is the main reason to use such a library.**

Key Features

Safety

Performance

  • Compile-time logic via immediate (consteval) functions
  • Performance on par with (sometimes better than) fundamental types
  • Zero space overhead for high-level abstractions

Great User Experience

Feature Rich

Easy to Extend

Low Standardization Cost

  • Few predefined entities due to high composability
  • No external dependencies (with full C++20 support)
  • Macro-free user interface (aside from portability / standard-compliance helpers)
  • Plausible candidate for freestanding standardization