[clang-format]

This commit is contained in:
Jonas Hoppe
2024-09-10 09:58:05 +02:00
parent ee4a7066ca
commit f651438f29
13 changed files with 104 additions and 97 deletions

View File

@@ -49,7 +49,8 @@ struct delta_ {
template<Reference R>
struct absolute_ {
template<typename FwdRep, RepresentationOf<get_quantity_spec(R{}).character> Rep = std::remove_cvref_t<FwdRep>>
[[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION_WORKAROUND(R{}), default_point_origin(R{}), Rep> operator()(FwdRep&& lhs) const
[[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION_WORKAROUND(R{}), default_point_origin(R{}), Rep>
operator()(FwdRep&& lhs) const
{
return quantity_point{quantity{std::forward<FwdRep>(lhs), R{}}};
}

View File

@@ -188,8 +188,7 @@ struct expr_consolidate_impl<type_list<T, T, Rest...>> {
// replaces the instance of a type and a power of it with one with incremented power
template<typename T, int... Ints, typename... Rest>
struct expr_consolidate_impl<type_list<T, power<T, Ints...>, Rest...>> {
using type =
expr_consolidate_impl<type_list<power_or_T<T, power<T, Ints...>::exponent + 1>, Rest...>>::type;
using type = expr_consolidate_impl<type_list<power_or_T<T, power<T, Ints...>::exponent + 1>, Rest...>>::type;
};
// accumulates the powers of instances of the same type (removes the element in case the accumulation result is `0`)

View File

@@ -53,13 +53,15 @@ template<PointOrigin PO>
struct point_origin_interface {
template<PointOrigin PO, typename FwdQ, QuantityOf<PO::quantity_spec> Q = std::remove_cvref_t<FwdQ>>
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep> operator+(PO, FwdQ&& q)
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep>
operator+(PO, FwdQ&& q)
{
return quantity_point{std::forward<FwdQ>(q), PO{}};
}
template<Quantity FwdQ, PointOrigin PO, QuantityOf<PO::quantity_spec> Q = std::remove_cvref_t<FwdQ>>
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep> operator+(FwdQ&& q, PO po)
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep>
operator+(FwdQ&& q, PO po)
{
return po + std::forward<FwdQ>(q);
}

View File

@@ -667,7 +667,7 @@ template<QuantitySpec Q>
// dimension_one is always the last one
// otherwise, sort by typename
template<Dimension D1, Dimension D2>
[[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs)
[[nodiscard]] consteval bool ingredients_dimension_less(D1, D2)
{
if constexpr (D1{} == D2{} || D1{} == dimension_one)
return false;
@@ -1344,8 +1344,8 @@ template<QuantitySpec From, QuantitySpec To>
get_complexity(From{}) == get_complexity(To{}))
return convertible_impl(from_kind, to_kind);
else if constexpr (get_complexity(From{}) > get_complexity(To{}))
return exploded_kind_result(convertible_impl(
get_kind_tree_root(explode<get_complexity(To{})>(from_kind).quantity),to_kind));
return exploded_kind_result(
convertible_impl(get_kind_tree_root(explode<get_complexity(To{})>(from_kind).quantity), to_kind));
else
return exploded_kind_result(
convertible_impl(from_kind, get_kind_tree_root(explode<get_complexity(From{})>(to_kind).quantity)));

View File

@@ -87,7 +87,8 @@ struct reference {
}
template<typename Q2, typename U2>
[[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} * Q2{}), MP_UNITS_EXPRESSION_WORKAROUND(U{} * U2{})>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION_WORKAROUND(Q{} * Q2{}),
MP_UNITS_EXPRESSION_WORKAROUND(U{} * U2{})>
operator*(reference, reference<Q2, U2>)
{
return {};
@@ -110,7 +111,8 @@ struct reference {
}
template<typename Q2, typename U2>
[[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} / Q2{}), MP_UNITS_EXPRESSION_WORKAROUND(U{} / U2{})>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION_WORKAROUND(Q{} / Q2{}),
MP_UNITS_EXPRESSION_WORKAROUND(U{} / U2{})>
operator/(reference, reference<Q2, U2>)
{
return {};
@@ -291,8 +293,7 @@ template<Reference R1, Reference R2, Reference... Rest>
} -> Unit;
}
{
return detail::reference_t<
common_quantity_spec(get_quantity_spec(R1{}), get_quantity_spec(R2{}),
return detail::reference_t<common_quantity_spec(get_quantity_spec(R1{}), get_quantity_spec(R2{}),
get_quantity_spec(rest)...),
common_unit(get_unit(R1{}), get_unit(R2{}), get_unit(rest)...)>{};
}

View File

@@ -87,7 +87,8 @@ template<ReferenceOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto R,
template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { asin(v); } || requires(Rep v) { std::asin(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto asin(const quantity<R, Rep>& q) noexcept
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto asin(
const quantity<R, Rep>& q) noexcept
{
using std::asin;
if constexpr (!treat_as_floating_point<Rep>) {
@@ -101,7 +102,8 @@ template<ReferenceOf<dimensionless> auto R, typename Rep>
template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { acos(v); } || requires(Rep v) { std::acos(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto acos(const quantity<R, Rep>& q) noexcept
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto acos(
const quantity<R, Rep>& q) noexcept
{
using std::acos;
if constexpr (!treat_as_floating_point<Rep>) {
@@ -115,7 +117,8 @@ template<ReferenceOf<dimensionless> auto R, typename Rep>
template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { atan(v); } || requires(Rep v) { std::atan(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto atan(const quantity<R, Rep>& q) noexcept
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto atan(
const quantity<R, Rep>& q) noexcept
{
using std::atan;
if constexpr (!treat_as_floating_point<Rep>) {

View File

@@ -20,16 +20,17 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/hacks.h>
#include <mp-units/format.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/isq.h>
#include <mp-units/systems/si.h>
#include <mp-units/bits/hacks.h>
#include <iostream>
using namespace mp_units;
constexpr QuantityOf<isq::speed> auto avg_speed(QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::distance)> auto d, QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::duration)> auto t)
constexpr QuantityOf<isq::speed> auto avg_speed(QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::distance)> auto d,
QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::duration)> auto t)
{
return d / t;
}