Skip to content

Commit b230544

Browse files
author
Nic Holthaus
committed
CICD: seperate workflows for each compiler
1 parent 2d12992 commit b230544

File tree

6 files changed

+175
-141
lines changed

6 files changed

+175
-141
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 105 deletions
This file was deleted.

.github/workflows/clang-19.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI Pipeline - Clang
2+
3+
on:
4+
push:
5+
branches: [ '**' ] # Run on all branches
6+
pull_request:
7+
branches: [ '**' ] # Run on all branches
8+
9+
jobs:
10+
build-ubuntu-clang:
11+
name: Build on Ubuntu Latest with Clang-19
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up Locales
16+
run: |
17+
sudo apt update
18+
sudo apt install -y locales
19+
sudo locale-gen de_DE.UTF-8 en_US.UTF-8
20+
sudo update-locale LANG=en_US.UTF-8
21+
22+
- name: Add LLVM Official Repository
23+
run: |
24+
sudo apt install -y software-properties-common wget
25+
wget https://apt.llvm.org/llvm.sh
26+
chmod +x llvm.sh
27+
sudo ./llvm.sh 19 # Install Clang-19 (latest stable)
28+
29+
- name: Install Latest Clang
30+
run: |
31+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 90
32+
clang++ --version
33+
34+
- name: Checkout Repository
35+
uses: actions/checkout@v4
36+
37+
- name: Configure CMake
38+
run: |
39+
cmake -B build -DCMAKE_CXX_COMPILER=clang++-19
40+
41+
- name: Build
42+
run: |
43+
cmake --build build --config Release
44+
45+
- name: Run Tests
46+
working-directory: build
47+
run: ctest --output-on-failure

.github/workflows/gcc-13.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI Pipeline - GCC
2+
3+
on:
4+
push:
5+
branches: [ '**' ] # Run on all branches
6+
pull_request:
7+
branches: [ '**' ] # Run on all branches
8+
9+
jobs:
10+
build-ubuntu-gcc:
11+
name: Build on Ubuntu Latest with GCC-13
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up Locales
16+
run: |
17+
sudo apt update
18+
sudo apt install -y locales
19+
sudo locale-gen de_DE.UTF-8 en_US.UTF-8
20+
sudo update-locale LANG=en_US.UTF-8
21+
22+
- name: Add GCC Toolchain PPA
23+
run: |
24+
sudo apt install -y software-properties-common
25+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
26+
sudo apt update
27+
28+
- name: Install GCC-13
29+
run: |
30+
sudo apt install -y g++-13
31+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 90
32+
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
36+
- name: Configure CMake
37+
run: |
38+
cmake -B build -DCMAKE_CXX_COMPILER=g++-13
39+
40+
- name: Build
41+
run: |
42+
cmake --build build --config Release
43+
44+
- name: Run Tests
45+
working-directory: build
46+
run: ctest --output-on-failure
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI Pipeline - Windows
2+
3+
on:
4+
push:
5+
branches: [ '**' ] # Run on all branches
6+
pull_request:
7+
branches: [ '**' ] # Run on all branches
8+
9+
jobs:
10+
build-windows:
11+
name: Build on Windows with Visual Studio 2022
12+
runs-on: windows-latest
13+
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Configure CMake
19+
run: |
20+
cmake -B build -G "Visual Studio 17 2022" -A x64
21+
22+
- name: Build
23+
run: |
24+
cmake --build build --config Release
25+
26+
- name: Run Tests
27+
working-directory: build
28+
run: ctest -C Release --output-on-failure

include/units/core.h

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,51 +4150,67 @@ namespace std
41504150
// UNIT DEDUCTION GUIDES
41514151
//------------------------------
41524152

4153-
namespace units
4154-
{
4153+
namespace units {
4154+
4155+
// Concept to ensure we only apply the dimensionless fallback
4156+
// to a pure, unmodified dimensionless unit.
4157+
template<class Cf>
4158+
concept PureDimensionlessCF =
4159+
std::is_same_v<typename Cf::dimension_type, dimension::dimensionless> &&
4160+
std::ratio_equal_v<typename Cf::conversion_ratio, std::ratio<1>> &&
4161+
std::ratio_equal_v<typename Cf::pi_exponent_ratio, std::ratio<0>> &&
4162+
std::ratio_equal_v<typename Cf::translation_ratio, std::ratio<0>>;
4163+
41554164
// 1) chrono deduction guide
41564165
template<ArithmeticType Rep, RatioType Period>
4157-
unit(std::chrono::duration<Rep, Period>)
4158-
-> unit<conversion_factor<Period, dimension::time>, Rep>;
4166+
unit(std::chrono::duration<Rep, Period>) -> unit<conversion_factor<Period, dimension::time>, Rep>;
41594167

41604168
// 2) Dimensionless fallback:
4161-
// Now restricted to apply only if the source is exactly the base dimensionless unit,
4162-
// i.e. conversion_factor<std::ratio<1>, dimension::dimensionless> with no pi exponent or translation.
4169+
// Only applies if the source is exactly the base dimensionless unit.
41634170
template<ArithmeticType SourceTy, ConversionFactorType SourceCf>
4164-
requires (
4165-
traits::is_unit_v<unit<SourceCf, SourceTy>> &&
4166-
std::is_same_v<typename SourceCf::dimension_type, dimension::dimensionless> &&
4167-
// Ensuring it's the pure base dimensionless factor:
4168-
std::ratio_equal<typename SourceCf::conversion_ratio, std::ratio<1>>::value &&
4169-
std::ratio_equal<typename SourceCf::pi_exponent_ratio, std::ratio<0>>::value &&
4170-
std::ratio_equal<typename SourceCf::translation_ratio, std::ratio<0>>::value
4171-
)
4172-
unit(const unit<SourceCf, SourceTy>&)
4173-
-> unit<conversion_factor<std::ratio<1>, dimension::dimensionless>, SourceTy>;
4174-
4175-
// 3) General conversion factor from Target, type from Source:
4176-
// Applies only if TargetCf differs from SourceCf and they share the same dimension.
4171+
requires(
4172+
traits::is_unit_v<unit<SourceCf, SourceTy>> &&
4173+
PureDimensionlessCF<SourceCf>
4174+
)
4175+
unit(const unit<SourceCf, SourceTy>&) -> unit<conversion_factor<std::ratio<1>, dimension::dimensionless>, SourceTy>;
4176+
4177+
// 3) Lossless integral conversion:
4178+
// For dimensionally compatible units where the conversion is integral and lossless.
4179+
// This applies only if is_losslessly_convertible_unit is true.
41774180
template<ArithmeticType SourceTy, ConversionFactorType SourceCf, ConversionFactorType TargetCf = SourceCf>
4178-
requires (
4179-
traits::is_unit_v<unit<SourceCf, SourceTy>> &&
4180-
traits::is_conversion_factor_v<TargetCf> &&
4181-
traits::is_same_dimension_conversion_factor_v<SourceCf, TargetCf> &&
4182-
!std::is_same_v<SourceCf, TargetCf>
4183-
)
4181+
requires(
4182+
traits::is_unit_v<unit<SourceCf, SourceTy>> &&
4183+
traits::is_conversion_factor_v<TargetCf> &&
4184+
traits::is_same_dimension_conversion_factor_v<SourceCf, TargetCf> &&
4185+
!std::is_same_v<SourceCf, TargetCf> &&
4186+
detail::is_losslessly_convertible_unit<unit<SourceCf, SourceTy>, unit<TargetCf, SourceTy>>
4187+
)
41844188
unit(const unit<SourceCf, SourceTy>&) -> unit<TargetCf, SourceTy>;
41854189

4186-
// 4) Matching Target and Source factors exactly
4190+
// 4) Non-lossless conversions:
4191+
// For dimensionally compatible units where integral conversion is not possible.
4192+
// Falls back to floating point.
4193+
template<ArithmeticType SourceTy, ConversionFactorType SourceCf, ConversionFactorType TargetCf = SourceCf>
4194+
requires(
4195+
traits::is_unit_v<unit<SourceCf, SourceTy>> &&
4196+
traits::is_conversion_factor_v<TargetCf> &&
4197+
traits::is_same_dimension_conversion_factor_v<SourceCf, TargetCf> &&
4198+
!std::is_same_v<SourceCf, TargetCf> &&
4199+
!detail::is_losslessly_convertible_unit<unit<SourceCf, SourceTy>, unit<TargetCf, SourceTy>>
4200+
)
4201+
unit(const unit<SourceCf, SourceTy>&) -> unit<TargetCf, detail::floating_point_promotion_t<SourceTy>>;
4202+
4203+
// 5) Exact matches:
4204+
// If the unit already matches `unit<TargetCf, SourceTy>`, use it directly.
41874205
template<ConversionFactorType TargetCf, ArithmeticType SourceTy>
4188-
requires traits::is_unit_v<unit<TargetCf, SourceTy>>
4206+
requires traits::is_unit_v<unit<TargetCf, SourceTy>>
41894207
unit(const unit<TargetCf, SourceTy>&) -> unit<TargetCf, SourceTy>;
41904208

4191-
// 5) Deduce type from arithmetic type (dimensionless by default)
4192-
template<typename T,
4193-
typename Cf = dimension::dimensionless,
4194-
typename = std::enable_if_t<std::is_arithmetic_v<T>>>
4209+
// 6) Deduce type from arithmetic type (dimensionless by default)
4210+
template<typename T, typename Cf = dimension::dimensionless, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
41954211
unit(T) -> unit<Cf, T>;
4196-
} // namespace units
41974212

4213+
} // namespace units
41984214

41994215

42004216
//----------------------------------------------------------------------------------------------------------------------

unitTests/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ TEST_F(UnitType, constructionFromUnitType)
890890

891891
TEST_F(UnitType, CTAD)
892892
{
893-
#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L
894893
// Default ctor
895894
constexpr meters z_m{};
896895
static_assert(std::is_same_v<std::remove_const_t<decltype(z_m)>, meters<double>>);
@@ -950,7 +949,6 @@ TEST_F(UnitType, CTAD)
950949

951950
constexpr meters m_m(millimeters<double>(1.0));
952951
static_assert(std::is_same_v<std::remove_const_t<decltype(m_m)>, meters<double>>);
953-
#endif // defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L
954952

955953
// `std::chrono::duration`.
956954
using namespace std::chrono_literals;
@@ -961,7 +959,6 @@ TEST_F(UnitType, CTAD)
961959
constexpr unit a_min(1.0min);
962960
static_assert(minutes<double>(1.0) == a_min && std::is_floating_point_v<decltype(a_min.value())>);
963961

964-
#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L
965962
constexpr seconds b_s(1_s);
966963
static_assert(std::is_integral_v<decltype(b_s.value())>);
967964

@@ -1025,7 +1022,12 @@ TEST_F(UnitType, CTAD)
10251022

10261023
constexpr dimensionless m_dim(unit<conversion_factor<std::milli, dimensionless_>, double>(1.0));
10271024
static_assert(std::is_same_v<std::remove_const_t<decltype(m_dim)>, dimensionless<double>>);
1028-
#endif // defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L
1025+
1026+
constexpr radians n_dim(degrees{1});
1027+
static_assert(std::is_same_v<std::remove_const_t<decltype(n_dim)>, radians<double>>);
1028+
1029+
constexpr radians o_dim(degrees{1.0});
1030+
static_assert(std::is_same_v<std::remove_const_t<decltype(n_dim)>, radians<double>>);
10291031
}
10301032

10311033
TEST_F(UnitType, implicitChronoConversions)

0 commit comments

Comments
 (0)