Files
mp-units/README.md
T

97 lines
3.8 KiB
Markdown
Raw Normal View History

2019-10-04 20:21:05 +02:00
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?maxAge=3600)](./LICENSE.md)
2019-05-08 09:52:46 -06:00
[![Travis CI](https://img.shields.io/travis/com/mpusz/units/master.svg?label=Travis%20CI)](https://travis-ci.com/mpusz/units)
2019-10-04 08:29:24 +02:00
[![Conan stable](https://api.bintray.com/packages/mpusz/conan-mpusz/mp-units%3Ampusz/images/download.svg?version=0.3.1%3Astable)](https://bintray.com/mpusz/conan-mpusz/mp-units%3Ampusz/0.3.1%3Astable/link)
[![Conan testing](https://api.bintray.com/packages/mpusz/conan-mpusz/mp-units%3Ampusz/images/download.svg)](https://bintray.com/mpusz/conan-mpusz/mp-units%3Ampusz/_latestVersion)
2019-09-17 06:46:10 -06:00
# `mp-units` - A Units Library for C++
2018-08-22 12:11:19 +02:00
2018-11-17 12:40:06 +01:00
## 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
2019-10-04 08:29:24 +02:00
`std::chrono::duration` and extends it to work properly with many dimensions.
2018-11-17 12:40:06 +01:00
2018-11-17 15:24:06 +01:00
Here is a small example of possible operations:
2018-11-17 12:40:06 +01:00
```cpp
2019-04-10 17:20:32 +01:00
// simple numeric operations
static_assert(10_km / 2 == 5_km);
// unit conversions
2018-11-17 12:40:06 +01:00
static_assert(1_h == 3600_s);
static_assert(1_km + 1_m == 1001_m);
2019-04-10 17:20:32 +01:00
// dimension conversions
2018-11-17 12:40:06 +01:00
static_assert(1_km / 1_s == 1000_mps);
static_assert(2_kmph * 2_h == 4_km);
static_assert(2_km / 2_kmph == 1_h);
2019-04-10 17:20:32 +01:00
static_assert(1000 / 1_s == 1_kHz);
static_assert(10_km / 5_km == 2);
2018-11-17 12:40:06 +01:00
```
## Repository structure
2019-03-07 21:23:50 +01:00
2019-05-08 09:52:46 -06:00
That repository contains the following independent `cmake`-based projects:
2019-10-04 08:29:24 +02:00
- `./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
2019-05-08 09:52:46 -06:00
Please note that the projects depend on `cmake` git submodule in the `./cmake/common`
subdirectory.
2018-11-17 12:40:06 +01:00
2019-05-08 09:52:46 -06:00
## Building, testing, and installation
2018-11-17 12:40:06 +01:00
2019-05-08 09:52:46 -06:00
For a detailed information on project compilation, testing and reuse please refer to
[doc/INSTALL.md](doc/INSTALL.md).
2018-11-17 12:40:06 +01:00
2019-08-05 18:35:18 +02:00
NOTE: This library as of now compiles correctly only with gcc-9.1 and newer.
2018-11-17 12:40:06 +01:00
## Library design
2018-11-17 12:40:06 +01:00
2019-10-04 08:29:24 +02:00
`mp-units` library design rationale and documentation can be found in
[doc/DESIGN.md](doc/DESIGN.md)
2019-05-18 13:01:09 +02:00
## Release notes
2019-09-18 10:31:58 -06:00
- 0.4.0 ???
2019-09-18 21:59:57 -06:00
- Support for derived dimensions in `exp` added
- Added `pow()` and `sqrt()` operations on quantities
- `units` removed from a `std::experimental` namespace
- Downcasting facility refactored so the user does not have to write the boilerplate code anymore
2019-09-18 10:31:58 -06:00
- 0.3.1 Sep 18, 2019
- cmcstl2 dependency changed to range-v3 0.9.1
2019-09-17 06:52:22 -06:00
- 0.3.0 Sep 16, 2019 (CppCon 2019 design)
2019-10-04 08:29:24 +02:00
- The design as described on CppCon 2019 talk (<https://youtu.be/0YW6yxkdhlU>)
2019-08-05 18:35:18 +02:00
- Applied the feedback from the Cologne evening session
- `upcasting_traits` renamed to `downcasting_traits`
- `Dimension` template parameter removed from quantity
- `units` moved to a `std::experimental` namespace
- Leading underscore prefix removed from UDLs
- Added a few more derived dimensions
- `meter` renamed to `metre`
2019-10-04 08:29:24 +02:00
- Missing `operator*` added
- Predefined dimensions moved to a dedicated directory
- `dimension_` prefix removed from names of derived dimensions
2019-09-17 06:46:10 -06:00
- cmcstl2 library updated to 2019.09.19
- `base_dimension` is a value provided as `const&` to the `exp` type
- integrated with Compiler Explorer
2019-10-04 08:29:24 +02:00
- gsl-lite dependency removed
2019-09-17 06:46:10 -06:00
- Fractional dimension exponents support added
- `QuantityOf` concept introduced
2019-10-04 08:29:24 +02:00
- `quantity_cast<U, Rep>()` support added
2019-08-05 18:35:18 +02:00
2019-09-17 06:52:22 -06:00
- 0.2.0 July 18, 2019 (C++Now 2019 design)
2019-10-04 08:29:24 +02:00
- The design as described on C++Now 2019 talk (<https://youtu.be/wKchCktZPHU>)
2019-09-17 07:08:32 -06:00
- Added C++20 features supported by gcc-9.1 (`std::remove_cvref_t`, down with typename, `std::type_identity`)
2019-10-04 08:29:24 +02:00
- Compile-time performance optimizations (`type_list`, `common_ratio`, `ratio`, `conditional_t`)
2019-05-18 13:01:09 +02:00
- 0.1.0 May 18, 2019
- Initial library release
- Begin semantic versioning
2019-05-18 18:15:07 +02:00
- The last version to work with gcc-8