Skip to content

Commit

Permalink
Implementierung von convertible_units als Funktion
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfehrs committed Jan 24, 2024
1 parent 3cee698 commit 098b44c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/zollstock/scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ namespace zollstock
return -this->value_;
}

template <unit_c auto that_unit> requires convertible_units_c<unit_type, decltype(that_unit)>
template <unit_c auto that_unit> requires(convertible_units(this_unit, that_unit))
[[nodiscard]] constexpr scalar<that_unit, value_type> as() const noexcept
{
return this->as_impl<that_unit>(make_quantity_index_sequence{});
}

template <unit_c auto that_unit> requires convertible_units_c<unit_type, decltype(that_unit)>
template <unit_c auto that_unit> requires(convertible_units(this_unit, that_unit))
[[nodiscard]] constexpr operator scalar<that_unit, value_type>() const noexcept
{
return this->as<that_unit>();
Expand Down
8 changes: 4 additions & 4 deletions include/zollstock/unit_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace zollstock
{ Candidate::symbols } -> std::same_as<const quantity_symbols &>;
};

template <typename Unit1, typename Unit2>
concept convertible_units_c = unit_c<Unit1>
&& unit_c<Unit2>
&& Unit1::exponents == Unit2::exponents;
[[nodiscard]] consteval bool convertible_units(unit_c auto unit_1, unit_c auto unit_2) noexcept
{
return unit_1.exponents == unit_2.exponents;
}

template <unit_c Unit, int exponent_>
struct unit_exponentiation
Expand Down

0 comments on commit 098b44c

Please sign in to comment.