mirror of
https://github.com/mpusz/mp-units.git
synced 2026-02-11 17:39:00 +01:00
e5ee2cd38190fd20eedd23d30483291ca9bf035b
units - Physical Units Library for C++
Summary
Units is a compile-time enabled Modern C++ library that provides compile-time dimensional
analysis and unit/quantity manipulation. The basic idea and design heavily bases on
std::chrono::duration and extends it to work properly with many dimensions.
Here is a small example of possible operations:
// simple numeric operations
static_assert(10_km / 2 == 5_km);
// unit conversions
static_assert(1_h == 3600_s);
static_assert(1_km + 1_m == 1001_m);
// dimension conversions
static_assert(1_km / 1_s == 1000_mps);
static_assert(2_kmph * 2_h == 4_km);
static_assert(2_km / 2_kmph == 1_h);
static_assert(1000 / 1_s == 1_kHz);
static_assert(10_km / 5_km == 2);
Repository structure
That repository contains the following independent cmake-based projects:
./src- header-only project forunits.- project used for development needs that wraps./srcproject together with usage examples and unit tests./test_package- library installation and Conan package verification
Please note that the projects depend on cmake git submodule in the ./cmake/common
subdirectory.
Building, testing, and installation
For a detailed information on project compilation, testing and reuse please refer to doc/INSTALL.md.
Library design
units library design rationale and documentation can be found in
doc/DESIGN.md
Description
Languages
C++
66.6%
CMake
24.5%
Python
7.4%
C
0.9%
Shell
0.6%