Skip to content

Commit

Permalink
Merge branch 'v3.x' into v3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
nholthaus authored Dec 17, 2024
2 parents 3ccfe92 + 69a66b6 commit de6b5aa
Show file tree
Hide file tree
Showing 39 changed files with 2,331 additions and 1,769 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/clang-19.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: clang-19

on:
push:
branches: [ '**' ] # Run on all branches
pull_request:
branches: [ '**' ] # Run on all branches

jobs:
build-ubuntu-clang:
name: Build on Ubuntu Latest with Clang-19
runs-on: ubuntu-latest

steps:
- name: Set up Locales
run: |
sudo apt update
sudo apt install -y locales
sudo locale-gen de_DE.UTF-8 en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
- name: Add LLVM Official Repository
run: |
sudo apt install -y software-properties-common wget
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19 # Install Clang-19 (latest stable)
- name: Install Latest Clang
run: |
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 90
clang++ --version
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure CMake
run: |
cmake -B build -DCMAKE_CXX_COMPILER=clang++-19
- name: Build
run: |
cmake --build build --config Release
- name: Run Tests
working-directory: build
run: ctest --output-on-failure
46 changes: 46 additions & 0 deletions .github/workflows/gcc-13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: g++-13

on:
push:
branches: [ '**' ] # Run on all branches
pull_request:
branches: [ '**' ] # Run on all branches

jobs:
build-ubuntu-gcc:
name: Build on Ubuntu Latest with GCC-13
runs-on: ubuntu-latest

steps:
- name: Set up Locales
run: |
sudo apt update
sudo apt install -y locales
sudo locale-gen de_DE.UTF-8 en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
- name: Add GCC Toolchain PPA
run: |
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
- name: Install GCC-13
run: |
sudo apt install -y g++-13
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 90
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure CMake
run: |
cmake -B build -DCMAKE_CXX_COMPILER=g++-13
- name: Build
run: |
cmake --build build --config Release
- name: Run Tests
working-directory: build
run: ctest --output-on-failure
28 changes: 28 additions & 0 deletions .github/workflows/msvc-2022.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: msvc-2022

on:
push:
branches: [ '**' ] # Run on all branches
pull_request:
branches: [ '**' ] # Run on all branches

jobs:
build-windows:
name: Build on Windows with Visual Studio 2022
runs-on: windows-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure CMake
run: |
cmake -B build -G "Visual Studio 17 2022" -A x64
- name: Build
run: |
cmake --build build --config Release
- name: Run Tests
working-directory: build
run: ctest -C Release --output-on-failure
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
cmake_minimum_required(VERSION 3.16...3.31 FATAL_ERROR)

PROJECT(units VERSION 3.0.0 LANGUAGES CXX)
PROJECT(units VERSION 3.1.0 LANGUAGES CXX)

# check if this is the main project
set(MAIN_PROJECT OFF)
Expand All @@ -14,7 +14,7 @@ OPTION(UNITS_BUILD_DOCS "Build the documentation" OFF)
OPTION(UNITS_DISABLE_IOSTREAM "Disables <iostream> (cout) support for embedded applications" OFF)
option(UNITS_CODE_COVERAGE "Generate coveralls code coverage data" OFF)

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD 23)

# header-only library target. To use this project as a subdirectory,
# add the following to your code:
Expand All @@ -41,6 +41,7 @@ if(BUILD_TESTING AND UNITS_BUILD_TESTS)
find_package(Threads)
find_package(GTest 1.12.1)
if (NOT GTest_FOUND)
message(STATUS "No system googletest found. Using project-provided gtest v1.12.1")
add_subdirectory(3rdParty/googletest-1.12.1)
endif()
add_subdirectory(unitTests)
Expand Down
33 changes: 10 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,23 @@

A compile-time, header-only, dimensional analysis library built on C++17 with no dependencies.

[![Linux build](https://travis-ci.org/nholthaus/units.svg?branch=master)](https://travis-ci.org/nholthaus/units) [![Windows build](https://ci.appveyor.com/api/projects/status/github/nholthaus/units?svg=true&branch=master)](https://ci.appveyor.com/project/nholthaus/units) [![Coverage Status](https://coveralls.io/repos/github/nholthaus/units/badge.svg?branch=master)](https://coveralls.io/github/nholthaus/units?branch=master) ![license](https://img.shields.io/badge/license-MIT-orange.svg) ![copyright](https://img.shields.io/badge/%C2%A9-Nic_Holthaus-orange.svg) ![language](https://img.shields.io/badge/language-c++-blue.svg) ![c++](https://img.shields.io/badge/std-c++14-blue.svg)<br>![msvc2015](https://img.shields.io/badge/MSVC-2015-ff69b4.svg) ![msvc2017](https://img.shields.io/badge/MSVC-2017-ff69b4.svg) ![gcc-4.9.3](https://img.shields.io/badge/GCC-4.9.3-ff69b4.svg) ![gcc-5.4.0](https://img.shields.io/badge/GCC-5.4.0-ff69b4.svg) ![clang-3.4](https://img.shields.io/badge/CLANG-3.4-ff69b4.svg)
![Windows build](https://github.com/nholthaus/units/actions/workflows/msvc-2022.yaml/badge.svg) ![GCC build](https://github.com/nholthaus/units/actions/workflows/gcc-13.yaml/badge.svg) ![Clang build](https://github.com/nholthaus/units/actions/workflows/clang-19.yaml/badge.svg) ![license](https://img.shields.io/badge/license-MIT-orange.svg) ![copyright](https://img.shields.io/badge/%C2%A9-Nic_Holthaus-orange.svg) ![language](https://img.shields.io/badge/language-c++-blue.svg) ![c++](https://img.shields.io/badge/std-c++23-blue.svg)

# Get in touch
<a id="markdown-get-in-touch" name="get-in-touch"></a>

If you are using `units.h` in production code, I'd love to hear from you via GitHub issues!
# Latest Release - v3.1.0
<a id="markdown-latest-release---v3.1.0" name="latest-release---v3.1.0"></a>

# Next Release - v3.0.0
## Get it
<a id="markdown-get-it" name="get-it"></a>

## New in v3.0.0
[![DOWNLOAD](https://img.shields.io/badge/Download-v3.1.0-green.svg)](https://github.com/nholthaus/units/releases/tag/v2.3.1)

> I got enamoured with this library because with a few lines
I could have a powerful type representing my domain-specific concept.
Being able to clearly express your domain in code leads to better designs.
My `Pixels` unit is as well-supported as any other unit in this library.
It has access to the expressiveness and dimensional analysis
that the library-defined units have.
It's amazing how this library lets me define this expressive domain unit
so succinctly and have access to so many useful things
in such a short amount of code. \
-- Johel Ernesto Guerrero Peña (@johelegp),
https://github.com/nholthaus/units/issues/124#issuecomment-390773279

# Latest Release - v2.3.1
<a id="markdown-latest-release---v2.3.1" name="latest-release---v2.3.1"></a>
## New in v3.1.0


## New in v3.0.0

## Get it
<a id="markdown-get-it" name="get-it"></a>

[![DOWNLOAD](https://img.shields.io/badge/Download-v2.3.1-green.svg)](https://github.com/nholthaus/units/releases/tag/v2.3.1)

## New in v2.3.1
<a id="markdown-new-in-v2.3.1" name="new-in-v2.3.1"></a>
Expand Down
29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

39 changes: 20 additions & 19 deletions include/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include <units/illuminance.h>
#include <units/impedance.h>
#include <units/inductance.h>
#include <units/jerk.h>
#include <units/length.h>
#include <units/luminance.h>
#include <units/luminous_flux.h>
Expand All @@ -91,7 +92,7 @@ namespace units
{
namespace detail
{
struct PI : conversion_factor<std::ratio<1>, dimensionless_unit, std::ratio<1>>
struct PI : conversion_factor<std::ratio<1>, dimensionless_, std::ratio<1>>
{
};
} // namespace detail
Expand All @@ -114,24 +115,24 @@ namespace units
*/

// clang-format off
inline constexpr const unit<detail::PI> pi(1); ///< Ratio of a circle's circumference to its diameter.
inline constexpr const meters_per_second<> c(299792458.0); ///< Speed of light in vacuum.
inline constexpr const unit<compound_conversion_factor<cubed<meters<>>, inverse<kilograms<>>, inverse<squared<seconds<>>>>> G(6.67430e-11); ///< Newtonian constant of gravitation.
inline constexpr const unit<compound_conversion_factor<joules<>, seconds<>>> h(6.62607015e-34); ///< Planck constant.
inline constexpr const unit<compound_conversion_factor<joules<>, seconds<>>> h_bar(1.054571817e-34); ///< Reduced Planck constant.
inline constexpr const unit<compound_conversion_factor<newtons<>, inverse<squared<amperes<>>>>> mu0(1.25663706212e-6); ///< vacuum permeability.
inline constexpr const unit<compound_conversion_factor<farads<>, inverse<meters<>>>> epsilon0(8.8541878128e-12); ///< vacuum permittivity.
inline constexpr const ohms<> Z0(376.730313668); ///< characteristic impedance of vacuum.
inline constexpr const unit<compound_conversion_factor<newtons<>, square_meters<>, inverse<squared<coulombs<>>>>> k_e(8.9875517923e9); ///< Coulomb's constant.
inline constexpr const coulombs<> e(1.602176634e-19); ///< elementary charge.
inline constexpr const kilograms<> m_e(9.1093837015e-31); ///< electron mass.
inline constexpr const kilograms<> m_p(1.67262192369e-27); ///< proton mass.
inline constexpr const unit<compound_conversion_factor<joules<>, inverse<magnetic_field_strength::teslas<>>>> mu_B(9.2740100783e-24); ///< Bohr Magneton.
inline constexpr const unit<inverse<mols<>>> N_A(6.02214076e23); ///< Avogadro's Number.
inline constexpr const unit<compound_conversion_factor<joules<>, inverse<kelvin<>>, inverse<mols<>>>> R(8.314462618); ///< Gas constant.
inline constexpr const unit<compound_conversion_factor<joules<>, inverse<kelvin<>>>> k_B(1.380649e-23); ///< Boltzmann constant.
inline constexpr const unit<compound_conversion_factor<coulombs<>, inverse<mols<>>>> F(96485.33212); ///< Faraday constant.
inline constexpr const unit<compound_conversion_factor<watts<>, inverse<square_meters<>>, inverse<squared<squared<kelvin<>>>>>> sigma(5.670374419e-8); ///< Stefan-Boltzmann constant.
inline constexpr unit<detail::PI> pi(1); ///< Ratio of a circle's circumference to its diameter.
inline constexpr meters_per_second c(299792458.0); ///< Speed of light in vacuum.
inline constexpr unit<compound_conversion_factor<cubed<meters_>, inverse<kilograms_>, inverse<squared<seconds_>>>> G(6.67430e-11); ///< Newtonian constant of gravitation.
inline constexpr unit<compound_conversion_factor<joules_, seconds_>> h(6.62607015e-34); ///< Planck constant.
inline constexpr unit<compound_conversion_factor<joules_, seconds_>> h_bar(1.054571817e-34); ///< Reduced Planck constant.
inline constexpr unit<compound_conversion_factor<newtons_, inverse<squared<amperes_>>>> mu0(1.25663706212e-6); ///< vacuum permeability.
inline constexpr unit<compound_conversion_factor<farads_, inverse<meters_>>> epsilon0(8.8541878128e-12); ///< vacuum permittivity.
inline constexpr ohms Z0(376.730313668); ///< characteristic impedance of vacuum.
inline constexpr unit<compound_conversion_factor<newtons_, square_meters_, inverse<squared<coulombs_>>>> k_e(8.9875517923e9); ///< Coulomb's constant.
inline constexpr coulombs e(1.602176634e-19); ///< elementary charge.
inline constexpr kilograms m_e(9.1093837015e-31); ///< electron mass.
inline constexpr kilograms m_p(1.67262192369e-27); ///< proton mass.
inline constexpr unit<compound_conversion_factor<joules_, inverse<teslas_>>> mu_B(9.2740100783e-24); ///< Bohr Magneton.
inline constexpr unit<inverse<mols_>> N_A(6.02214076e23); ///< Avogadro's Number.
inline constexpr unit<compound_conversion_factor<joules_, inverse<kelvin_>, inverse<mols_>>> R(8.314462618); ///< Gas constant.
inline constexpr unit<compound_conversion_factor<joules_, inverse<kelvin_>>> k_B(1.380649e-23); ///< Boltzmann constant.
inline constexpr unit<compound_conversion_factor<coulombs_, inverse<mols_>>> F(96485.33212); ///< Faraday constant.
inline constexpr unit<compound_conversion_factor<watts_, inverse<square_meters_>, inverse<squared<squared<kelvin_>>>>> sigma(5.670374419e-8); ///< Stefan-Boltzmann constant.
/** @} */
// clang-format on
} // namespace constants
Expand Down
6 changes: 3 additions & 3 deletions include/units/acceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ namespace units
* @sa See unit for more information on unit type containers.
*/
UNIT_ADD(acceleration, meters_per_second_squared, mps_sq, conversion_factor<std::ratio<1>, dimension::acceleration>)
UNIT_ADD(acceleration, feet_per_second_squared, fps_sq, compound_conversion_factor<feet<>, inverse<squared<seconds<>>>>)
UNIT_ADD(acceleration, standard_gravity, SG, conversion_factor<std::ratio<980665, 100000>, meters_per_second_squared<>>)
UNIT_ADD(acceleration, gals, Gal, compound_conversion_factor<centimeters<>, inverse<squared<seconds<>>>>)
UNIT_ADD(acceleration, feet_per_second_squared, fps_sq, compound_conversion_factor<feet_, inverse<squared<seconds_>>>)
UNIT_ADD(acceleration, standard_gravity, SG, conversion_factor<std::ratio<980665, 100000>, meters_per_second_squared_>)
UNIT_ADD(acceleration, gals, Gal, compound_conversion_factor<centimeters_, inverse<squared<seconds_>>>)

UNIT_ADD_DIMENSION_TRAIT(acceleration)
} // namespace units
Expand Down
5 changes: 3 additions & 2 deletions include/units/angular_velocity.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ namespace units
* @sa See unit for more information on unit type containers.
*/
UNIT_ADD(angular_velocity, radians_per_second, rad_per_s, conversion_factor<std::ratio<1>, dimension::angular_velocity>)
UNIT_ADD(angular_velocity, degrees_per_second, deg_per_s, compound_conversion_factor<degrees<>, inverse<seconds<>>>)
UNIT_ADD(angular_velocity, revolutions_per_minute, rpm, conversion_factor<std::ratio<2, 60>, radians_per_second<>, std::ratio<1>>)
UNIT_ADD(angular_velocity, degrees_per_second, deg_per_s, compound_conversion_factor<degrees_, inverse<seconds_>>)
UNIT_ADD(angular_velocity, revolutions_per_minute, rpm, conversion_factor<std::ratio<2, 60>, radians_per_second_, std::ratio<1>>)
UNIT_ADD(angular_velocity, revolutions_per_second, rps, conversion_factor<std::ratio<2, 1>, radians_per_second<>, std::ratio<1>>)
UNIT_ADD(angular_velocity, milliarcseconds_per_year, mas_per_yr, compound_conversion_factor<milliarcseconds<>, inverse<years<>>>)

UNIT_ADD_DIMENSION_TRAIT(angular_velocity)
Expand Down
12 changes: 6 additions & 6 deletions include/units/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ namespace units
* @sa See unit for more information on unit type containers.
*/
UNIT_ADD(area, square_meters, sq_m, conversion_factor<std::ratio<1>, dimension::area>)
UNIT_ADD(area, square_feet, sq_ft, squared<feet<>>)
UNIT_ADD(area, square_inches, sq_in, squared<inches<>>)
UNIT_ADD(area, square_miles, sq_mi, squared<miles<>>)
UNIT_ADD(area, square_kilometers, sq_km, squared<kilometers<>>)
UNIT_ADD(area, hectares, ha, conversion_factor<std::ratio<10000>, square_meters<>>)
UNIT_ADD(area, acres, acre, conversion_factor<std::ratio<43560>, square_feet<>>)
UNIT_ADD(area, square_feet, sq_ft, squared<feet_>)
UNIT_ADD(area, square_inches, sq_in, squared<inches_>)
UNIT_ADD(area, square_miles, sq_mi, squared<miles_>)
UNIT_ADD(area, square_kilometers, sq_km, squared<kilometers_>)
UNIT_ADD(area, hectares, ha, conversion_factor<std::ratio<10000>, square_meters_>)
UNIT_ADD(area, acres, acre, conversion_factor<std::ratio<43560>, square_feet_>)

UNIT_ADD_DIMENSION_TRAIT(area)
} // namespace units
Expand Down
2 changes: 1 addition & 1 deletion include/units/charge.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace units
* @sa See unit for more information on unit type containers.
*/
UNIT_ADD_WITH_METRIC_PREFIXES(charge, coulombs, C, conversion_factor<std::ratio<1>, dimension::charge>)
UNIT_ADD_WITH_METRIC_PREFIXES(charge, ampere_hours, Ah, compound_conversion_factor<amperes<>, hours<>>)
UNIT_ADD_WITH_METRIC_PREFIXES(charge, ampere_hours, Ah, compound_conversion_factor<amperes_, hours_>)

UNIT_ADD_DIMENSION_TRAIT(charge)
} // namespace units
Expand Down
Loading

0 comments on commit de6b5aa

Please sign in to comment.