Skip to content
forked from mpusz/mp-units

A Physical Units Library for C++ providing compile-time dimensional analysis and unit/quantity manipulation. Try it on Compiler Explorer (https://godbolt.org/z/_Yx6D7)

License

Notifications You must be signed in to change notification settings

oschonrock/units

Repository files navigation

GitHub license Travis CI AppVeyor Download

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:

static_assert(1000 / 1_s == 1_kHz);
static_assert(1_h == 3600_s);
static_assert(1_km + 1_m == 1001_m);
static_assert(10_km / 5_km == 2);
static_assert(10_km / 2 == 5_km);
static_assert(1_km / 1_s == 1000_mps);
static_assert(2_kmph * 2_h == 4_km);
static_assert(2_km / 2_kmph == 1_h);

Repository structure

That repository contains the following cmake-based projects:

  • ./src - header-only project for units
  • . - project used for development needs that wraps ./src project together with usage examples and unit tests
  • ./test_package - library installation and conan package verification

Please note that all projects depend on some cmake modules in ./cmake directory.

Building, testing and installation

For 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

About

A Physical Units Library for C++ providing compile-time dimensional analysis and unit/quantity manipulation. Try it on Compiler Explorer (https://godbolt.org/z/_Yx6D7)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CMake 50.2%
  • C++ 48.1%
  • Other 1.7%