Skip to content

Commit

Permalink
Merge pull request #96 from bernedom/feature/add_degree_t
Browse files Browse the repository at this point in the history
Feature/add degree t
  • Loading branch information
bernedom committed Oct 4, 2021
2 parents b73d9e3 + 0cab8b3 commit a0bb885
Show file tree
Hide file tree
Showing 47 changed files with 256 additions and 56 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
compiler-name-conan: clang

- name: macos-appleclang-11
os: macos-latest
os: macos-10.15

- name: windows-msvc-19
os: windows-latest
os: windows-2019

steps:
- uses: actions/checkout@v2
Expand All @@ -48,7 +48,9 @@ jobs:
- name: dependecies (macos)
if: runner.os == 'macOS'
run: brew install shunit2 ninja conan coreutils
run: |
brew update
brew install shunit2 ninja conan coreutils
- name: dependencies (windows)
if: runner.os == 'Windows'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.0

* Add `degree_t` to angle type including literals `_deg`

## 2.1.3

* Fix CI pipeline for windows
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)

project(
"SI"
VERSION 2.1.3
VERSION 2.2.0
DESCRIPTION
"A header only c++ library that provides type safety and user defined literals for handling pyhsical values defined in the International System of Units."
HOMEPAGE_URL "https://github.com/bernedom/SI"
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ The typedefs are prefixed (or in rare cases interfixed) with the standard metric
### Special Units
| Unit | Dimension Symbol | Exponent | Unit Symbol | implemented ratios | unit typedefs |
| ------------ | ---------------- | -------- | ----------- | ----------------------------------- | ------------------ |
| Area | L | 2 | m2 | 10<sup>-18</sup> to 10<sup>18</sup> | `square_*_metre_t` |
| Volume | L | 3 | m3 | 10<sup>-18</sup> to 10<sup>18</sup> | `cubic_*_metre_t` |
| Frequency | T | -1 | Hz | 10<sup>-18</sup> to 10<sup>18</sup> | `*_hertz_t` |
| Angle* | r | 1 | rad | 10<sup>-18</sup> to 1 | `*_radian_t` |
| Solid Angle* | R | 1 | sr | 10<sup>-18</sup> to 1 | `*_sterradian_t` |
\* Angle and solid angle are simple containers, not containing any functionality to do angle/room-angle computation such as an overflow after 2*pi.
| Unit | Dimension Symbol | Exponent | Unit Symbol | implemented ratios | unit typedefs |
| ---------------- | ---------------- | -------- | ----------- | ----------------------------------- | ------------------ |
| Area | L | 2 | m2 | 10<sup>-18</sup> to 10<sup>18</sup> | `square_*_metre_t` |
| Volume | L | 3 | m3 | 10<sup>-18</sup> to 10<sup>18</sup> | `cubic_*_metre_t` |
| Frequency | T | -1 | Hz | 10<sup>-18</sup> to 10<sup>18</sup> | `*_hertz_t` |
| Angle* | r | 1 | rad | 10<sup>-18</sup> to 1 | `*_radian_t` |
| Angle (Degrees)* | r | 1 | deg | micro, milli, 1 | `*_radian_t` |
| Solid Angle* | R | 1 | sr | 10<sup>-18</sup> to 1 | `*_sterradian_t` |
\* Angle, Angle (degree) and solid angle are simple containers, not containing any functionality to do angle/solid-angle computation such as an overflow after 2*pi. Converting between radians and degree might lose precision, especially if working with `long doubles` because the ratios not precise enough, as they have to be represented as long ints
## Derived units with special names
Expand Down
2 changes: 1 addition & 1 deletion include/SI/absorbed_dose.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/acceleration.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
48 changes: 47 additions & 1 deletion include/SI/angle.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down Expand Up @@ -28,11 +28,31 @@ template <typename _type> using micro_radian_t = angle_t<_type, std::micro>;
template <typename _type> using milli_radian_t = angle_t<_type, std::milli>;
template <typename _type> using radian_t = angle_t<_type, std::ratio<1>>;

template <typename _type>
using micro_degree_t = angle_t<_type, std::ratio<100000000, 5729577951308232>>;
template <typename _type>
using milli_degree_t =
angle_t<_type, std::ratio<100000000000, 5729577951308232>>;
template <typename _type>
using degree_t = angle_t<_type, std::ratio<100000000000000, 5729577951308232>>;

// specialize unit_symbol for usage with stream operators
template <>
struct unit_symbol<'r', std::ratio<1>>
: SI::detail::unit_symbol_impl<'r', 'a', 'd'> {};

template <>
struct unit_symbol<'r', std::ratio<100000000, 5729577951308232>>
: SI::detail::unit_symbol_impl<'u', 'd', 'e', 'g'> {};

template <>
struct unit_symbol<'r', std::ratio<100000000000, 5729577951308232>>
: SI::detail::unit_symbol_impl<'m', 'd', 'e', 'g'> {};

template <>
struct unit_symbol<'r', std::ratio<100000000000000, 5729577951308232>>
: SI::detail::unit_symbol_impl<'d', 'e', 'g'> {};

template <typename _ratio>
struct unit_symbol<'r', _ratio>
: SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'r',
Expand Down Expand Up @@ -102,6 +122,32 @@ constexpr radian_t<long double> operator""_rad(long double value) {
return radian_t<long double>{value};
}

template <char... _digits> constexpr micro_degree_t<int64_t> operator""_udeg() {
return micro_degree_t<int64_t>{
SI::detail::parsing::Number<_digits...>::value};
}

template <char... _digits> constexpr milli_degree_t<int64_t> operator""_mdeg() {
return milli_degree_t<int64_t>{
SI::detail::parsing::Number<_digits...>::value};
}

template <char... _digits> constexpr degree_t<int64_t> operator""_deg() {
return degree_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
}

constexpr micro_degree_t<long double> operator""_udeg(long double value) {
return micro_degree_t<long double>{value};
}

constexpr milli_degree_t<long double> operator""_mdeg(long double value) {
return milli_degree_t<long double>{value};
}

constexpr degree_t<long double> operator""_deg(long double value) {
return degree_t<long double>{value};
}

} // namespace literals

} // namespace SI
2 changes: 1 addition & 1 deletion include/SI/area.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/astronomic.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/catalytic_activity.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/cross_unit_operations.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/detail.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
3 changes: 2 additions & 1 deletion include/SI/detail/eps_equal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand All @@ -17,6 +17,7 @@

namespace SI::detail {

/// @todo make eps_equal take different types with similar properties
template <typename T, std::enable_if_t<std::is_floating_point_v<T>> * = nullptr>
constexpr bool eps_equals(const T &lhs, const T &rhs) {

Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/number_parser.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/operator_helpers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/unit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/unit_cast.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/detail/unit_symbol.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_capacity.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_charge.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_conductance.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_current.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_potential.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/electric_resistance.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/energy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/equivalent_dose.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/force.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/frequency.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/illuminance.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/inductance.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/length.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/luminosity.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/luminous_flux.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/magnetic_field.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/magnetic_flux.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/mass.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/momentum.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/power.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/pressure.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
2 changes: 1 addition & 1 deletion include/SI/radioactivity.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of "SI" version 2.1.3
* This file is part of "SI" version 2.2.0
* A header only c++ library that provides type safety and user defined literals
* for handling pyhsical values defined in the International System of
* Units
Expand Down
Loading

0 comments on commit a0bb885

Please sign in to comment.