style: clang-format new rules applied to the code base

This commit is contained in:
Mateusz Pusz
2023-05-26 14:20:00 +02:00
parent 561fbf7c93
commit 52bbd00ab4
20 changed files with 78 additions and 60 deletions

View File

@ -74,16 +74,16 @@ BraceWrapping:
# SplitEmptyFunction: true
SplitEmptyRecord: false
# SplitEmptyNamespace: true
# BreakAfterAttributes: Never
# BreakAfterJavaFieldAnnotations: false
# BreakArrays: true
# BreakBeforeBinaryOperators: None
# BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
# BreakBeforeInheritanceComma: false
BreakInheritanceList: AfterColon
# BreakBeforeInlineASMColon: OnlyMultiline
# BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
# BreakInheritanceList: BeforeColon
BreakInheritanceList: AfterColon
# BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: "^ NOLINT"
@ -92,7 +92,6 @@ CommentPragmas: "^ NOLINT"
# ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 2
# Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
# DisableFormat: false
# EmptyLineAfterAccessModifier: Never
@ -129,11 +128,20 @@ IncludeCategories:
# IndentWidth: 2
# IndentWrappedFunctionNames: false
# InsertBraces: false
# InsertNewlineAtEOF: false
# InsertTrailingCommas: None
# IntegerLiteralSeparator:
# Binary: 0
# BinaryMinDigits: 0
# Decimal: 0
# DecimalMinDigits: 0
# Hex: 0
# HexMinDigits: 0
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: false
# LambdaBodyIndentation: Signature
# LineEnding: DeriveLF
# MacroBlockBegin: ''
# MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
@ -197,7 +205,7 @@ QualifierAlignment: Left
# ShortNamespaceLines: 1
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
# SortUsingDeclarations: true
# SortUsingDeclarations: LexicographicNumeric
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
@ -239,7 +247,6 @@ SpaceBeforeParensOptions:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
# TabWidth: 8
# UseCRLF: false
# UseTab: Never
# WhitespaceSensitiveMacros:
# - BOOST_PP_STRINGIZE

View File

@ -58,7 +58,15 @@ add_example(
strong_angular_quantities mp-units::core-fmt mp-units::core-io mp-units::si mp-units::isq_angle mp-units::utility
)
add_example(total_energy mp-units::core-io mp-units::si mp-units::natural mp-units::utility)
add_example(unmanned_aerial_vehicle mp-units::core-fmt mp-units::core-io mp-units::si mp-units::international mp-units::utility example_utils)
add_example(
unmanned_aerial_vehicle
mp-units::core-fmt
mp-units::core-io
mp-units::si
mp-units::international
mp-units::utility
example_utils
)
add_subdirectory(glide_computer)
add_subdirectory(kalman_filter)

View File

@ -88,4 +88,4 @@ int main()
std::cout << price_usd.absolute() << " -> " << price_euro.absolute() << "\n";
// std::cout << price_usd.absolute() + price_euro.absolute() << "\n"; // does not compile
}
}

View File

@ -106,7 +106,7 @@ int main()
.speed{28.3 * kt},
.mass{42'245 * imperial::long_ton},
.mainGuns{14 * in},
.shellMass{1'590 * lb},
.shellMass{1590 * lb},
.shellSpeed{2483. * (ft / s)},
.power{110'000 * hp}};

View File

@ -84,10 +84,11 @@ void print(const R& gliders)
std::cout << "- Polar:\n";
for (const auto& p : g.polar) {
const auto ratio = value_cast<one>(glide_ratio(g.polar[0]));
std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, ratio,
// TODO is it possible to make ADL work below (we need another set of trig functions
// for strong angle in a different namespace)
value_cast<si::degree>(isq::asin(1 / ratio)));
std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v,
ratio,
// TODO is it possible to make ADL work below (we need another set of trig
// functions for strong angle in a different namespace)
value_cast<si::degree>(isq::asin(1 / ratio)));
}
std::cout << "\n";
}

View File

@ -50,8 +50,8 @@ int main()
using state = kalman::state<quantity<isq::mass[g]>>;
const state initial = {1 * kg};
const std::array measurements = {1'030 * g, 989 * g, 1'017 * g, 1'009 * g, 1'013 * g,
979 * g, 1'008 * g, 1'042 * g, 1'012 * g, 1'011 * g};
const std::array measurements = {1'030 * g, 989 * g, 1'017 * g, 1'009 * g, 1'013 * g,
979 * g, 1'008 * g, 1'042 * g, 1'012 * g, 1'011 * g};
print_header(initial);
state next = initial;

View File

@ -54,8 +54,9 @@ int main()
const auto interval = isq::duration(5 * s);
const state initial = {30 * km, 40 * (m / s)};
const quantity<isq::position_vector[m], int> measurements[] = {30'110 * m, 30'265 * m, 30'740 * m, 30'750 * m, 31'135 * m,
31'015 * m, 31'180 * m, 31'610 * m, 31'960 * m, 31'865 * m};
const quantity<isq::position_vector[m], int> measurements[] = {30'110 * m, 30'265 * m, 30'740 * m, 30'750 * m,
31'135 * m, 31'015 * m, 31'180 * m, 31'610 * m,
31'960 * m, 31'865 * m};
std::array gain = {0.2 * one, 0.1 * one};
print_header(initial);

View File

@ -54,8 +54,9 @@ int main()
const auto interval = isq::duration(5 * s);
const state initial = {30 * km, 50 * (m / s)};
const quantity<isq::position_vector[m], int> measurements[] = {30'160 * m, 30'365 * m, 30'890 * m, 31'050 * m, 31'785 * m,
32'215 * m, 33'130 * m, 34'510 * m, 36'010 * m, 37'265 * m};
const quantity<isq::position_vector[m], int> measurements[] = {30'160 * m, 30'365 * m, 30'890 * m, 31'050 * m,
31'785 * m, 32'215 * m, 33'130 * m, 34'510 * m,
36'010 * m, 37'265 * m};
std::array gain = {0.2 * one, 0.1 * one};
print_header(initial);

View File

@ -55,8 +55,9 @@ int main()
const auto interval = isq::duration(5. * s);
const state initial = {30 * km, 50 * (m / s), 0 * (m / s2)};
const quantity<isq::position_vector[m], int> measurements[] = {30'160 * m, 30'365 * m, 30'890 * m, 31'050 * m, 31'785 * m,
32'215 * m, 33'130 * m, 34'510 * m, 36'010 * m, 37'265 * m};
const quantity<isq::position_vector[m], int> measurements[] = {30'160 * m, 30'365 * m, 30'890 * m, 31'050 * m,
31'785 * m, 32'215 * m, 33'130 * m, 34'510 * m,
36'010 * m, 37'265 * m};
std::array gain = {0.5 * one, 0.4 * one, 0.1 * one};
print_header(initial);

View File

@ -36,19 +36,21 @@ int main()
std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n";
std::cout << UNITS_STD_FMT::format("- hyperfine transition frequency of Cs: {} = {:%.0Q %q}\n",
1. * si2019::hyperfine_structure_transition_frequency_of_cs,
(1. * si2019::hyperfine_structure_transition_frequency_of_cs)[Hz]);
1. * si2019::hyperfine_structure_transition_frequency_of_cs,
(1. * si2019::hyperfine_structure_transition_frequency_of_cs)[Hz]);
std::cout << UNITS_STD_FMT::format("- speed of light in vacuum: {} = {:%.0Q %q}\n",
1. * si2019::speed_of_light_in_vacuum, (1. * si2019::speed_of_light_in_vacuum)[m / s]);
1. * si2019::speed_of_light_in_vacuum,
(1. * si2019::speed_of_light_in_vacuum)[m / s]);
std::cout << UNITS_STD_FMT::format("- Planck constant: {} = {:%.8eQ %q}\n",
1. * si2019::planck_constant, (1. * si2019::planck_constant)[J * s]);
1. * si2019::planck_constant, (1. * si2019::planck_constant)[J * s]);
std::cout << UNITS_STD_FMT::format("- elementary charge: {} = {:%.9eQ %q}\n",
1. * si2019::elementary_charge, (1. * si2019::elementary_charge)[C]);
1. * si2019::elementary_charge, (1. * si2019::elementary_charge)[C]);
std::cout << UNITS_STD_FMT::format("- Boltzmann constant: {} = {:%.6eQ %q}\n",
1. * si2019::boltzmann_constant, (1. * si2019::boltzmann_constant)[J / K]);
1. * si2019::boltzmann_constant, (1. * si2019::boltzmann_constant)[J / K]);
std::cout << UNITS_STD_FMT::format("- Avogadro constant: {} = {:%.8eQ %q}\n",
1. * si2019::avogadro_constant, (1. * si2019::avogadro_constant)[1 / mol]);
1. * si2019::avogadro_constant, (1. * si2019::avogadro_constant)[1 / mol]);
// TODO uncomment the below when ISQ is done
// std::cout << UNITS_STD_FMT::format("- luminous efficacy: {} = {}\n", si2019::luminous_efficacy(1.),
// std::cout << UNITS_STD_FMT::format("- luminous efficacy: {} = {}\n",
// si2019::luminous_efficacy(1.),
// si2019::luminous_efficacy(1.)[lm / W]);
}

View File

@ -103,8 +103,8 @@ int main()
using namespace mp_units::si::unit_symbols;
const auto height = isq::height(200 * mm);
auto tank = RectangularStorageTank(isq::length(1000 * mm), isq::width(500 * mm), height);
tank.set_contents_density(1000 * isq::mass_density[kg / m3]);
auto tank = RectangularStorageTank(isq::length(1'000 * mm), isq::width(500 * mm), height);
tank.set_contents_density(1'000 * isq::mass_density[kg / m3]);
const auto fill_time = 200 * s; // time since starting fill
const auto measured_mass = 20. * kg; // measured mass at fill_time

View File

@ -162,6 +162,6 @@ int main()
};
waypoint wpt = {"EPPR", {54.24772_N, 18.6745_E}, msl_altitude{16. * ft}};
std::cout << UNITS_STD_FMT::format("{}: {} {}, {:%.2Q %q}, {:%.2Q %q}\n", wpt.name, wpt.pos.lat, wpt.pos.lon, wpt.msl_alt,
to_hae<earth_gravity_model::egm2008_1>(wpt.msl_alt, wpt.pos));
std::cout << UNITS_STD_FMT::format("{}: {} {}, {:%.2Q %q}, {:%.2Q %q}\n", wpt.name, wpt.pos.lat, wpt.pos.lon,
wpt.msl_alt, to_hae<earth_gravity_model::egm2008_1>(wpt.msl_alt, wpt.pos));
}

View File

@ -35,13 +35,11 @@ check_libcxx_in_use(${projectPrefix}LIBCXX)
add_library(
mp-units-core
INTERFACE
include/mp-units/bits/external/fixed_string.h
include/mp-units/bits/external/hacks.h
include/mp-units/bits/external/type_list.h
include/mp-units/bits/external/type_name.h
include/mp-units/bits/external/type_traits.h
include/mp-units/bits/algorithm.h
include/mp-units/bits/dimension_concepts.h
include/mp-units/bits/expression_template.h
@ -62,7 +60,6 @@ add_library(
include/mp-units/bits/text_tools.h
include/mp-units/bits/unit_concepts.h
include/mp-units/bits/value_cast.h
include/mp-units/concepts.h
include/mp-units/core.h
include/mp-units/customization_points.h

View File

@ -167,7 +167,7 @@ struct basic_symbol_text {
}
};
basic_symbol_text(char)->basic_symbol_text<char, 1, 1>;
basic_symbol_text(char) -> basic_symbol_text<char, 1, 1>;
template<typename UnicodeCharT>
basic_symbol_text(UnicodeCharT, char) -> basic_symbol_text<UnicodeCharT, 1, 1>;

View File

@ -73,7 +73,7 @@ struct reference {
}
template<AssociatedUnit U2>
[[nodiscard]] friend consteval reference<Q * get_quantity_spec(U2{}), U * U2{}> operator*(reference, U2)
[[nodiscard]] friend consteval reference<Q * get_quantity_spec(U2{}), U* U2{}> operator*(reference, U2)
{
return {};
}

View File

@ -43,7 +43,7 @@ inline constexpr struct candela : named_unit<"cd", kind_of<isq::luminous_intensi
// derived named units
inline constexpr struct radian : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
inline constexpr struct steradian : named_unit<"sr", square<metre> / square<metre>, kind_of<isq::solid_angular_measure>> {} steradian;
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
inline constexpr struct newton : named_unit<"N", kilogram * metre / square<second>> {} newton;
#ifdef pascal
#pragma push_macro("pascal")

View File

@ -31,8 +31,8 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
AlmostEqualsMatcher(const T& target) : target_{target} {}
template<std::convertible_to<T> U>
requires std::same_as<typename T::rep, typename U::rep> && treat_as_floating_point<typename T::rep> bool
match(const U& other) const
requires std::same_as<typename T::rep, typename U::rep> && treat_as_floating_point<typename T::rep>
bool match(const U& other) const
{
using std::abs;
using common = std::common_type_t<T, U>;

View File

@ -722,8 +722,8 @@ TEST_CASE("localization with the 'L' specifier", "[text][fmt][localization]")
SECTION("full format {:%LQ %q} on a quantity")
{
CHECK(UNITS_STD_FMT::format(grp2, "{:%LQ %q}", 299792458 * isq::speed[m / s]) == "2_99_79_24_58 m/s");
CHECK(UNITS_STD_FMT::format(grp3, "{:%LQ %q}", 299792458 * isq::speed[m / s]) == "299'792'458 m/s");
CHECK(UNITS_STD_FMT::format(grp2, "{:%LQ %q}", 299'792'458 * isq::speed[m / s]) == "2_99_79_24_58 m/s");
CHECK(UNITS_STD_FMT::format(grp3, "{:%LQ %q}", 299'792'458 * isq::speed[m / s]) == "299'792'458 m/s");
}
}

View File

@ -44,7 +44,7 @@ static_assert(check_primes<2>(std::make_index_sequence<122>{}));
// using numbers of the form (210 * n + 121) as trial divisors, which is a problem if any are prime. For n = 1, we have
// a divisor of (210 + 121 = 331), which happens to be prime but will not be used. Thus, (331 * 331 = 109561) is a
// composite number which could wrongly appear prime if we skip over 331.
static_assert(wheel_factorizer<4>::is_prime(109561) == is_prime_by_trial_division(109561));
static_assert(wheel_factorizer<4>::is_prime(109'561) == is_prime_by_trial_division(109'561));
static_assert(wheel_factorizer<1>::coprimes_in_first_wheel.size() == 1);
static_assert(wheel_factorizer<2>::coprimes_in_first_wheel.size() == 2);

View File

@ -760,10 +760,10 @@ static_assert(321. * m != 123 * m);
static_assert(!(123. * m == 321 * m));
static_assert(!(123. * m != 123 * m));
static_assert(123 * km == 123000 * m);
static_assert(321 * km != 123000 * m);
static_assert(!(123 * km == 321000 * m));
static_assert(!(123 * km != 123000 * m));
static_assert(123 * km == 123'000 * m);
static_assert(321 * km != 123'000 * m);
static_assert(!(123 * km == 321'000 * m));
static_assert(!(123 * km != 123'000 * m));
// dimensionless
static_assert(std::equality_comparable_with<quantity<dimensionless[one]>, double>);
@ -818,18 +818,18 @@ static_assert(!(123. * m > 321 * m));
static_assert(!(123. * m > 123 * m));
static_assert(!(123. * m >= 321 * m));
static_assert(123 * km < 321000 * m);
static_assert(123 * km <= 123000 * m);
static_assert(123 * km <= 321000 * m);
static_assert(321 * km > 123000 * m);
static_assert(123 * km >= 123000 * m);
static_assert(321 * km >= 123000 * m);
static_assert(!(321 * km < 123000 * m));
static_assert(!(123 * km < 123000 * m));
static_assert(!(321 * km <= 123000 * m));
static_assert(!(123 * km > 321000 * m));
static_assert(!(123 * km > 123000 * m));
static_assert(!(123 * km >= 321000 * m));
static_assert(123 * km < 321'000 * m);
static_assert(123 * km <= 123'000 * m);
static_assert(123 * km <= 321'000 * m);
static_assert(321 * km > 123'000 * m);
static_assert(123 * km >= 123'000 * m);
static_assert(321 * km >= 123'000 * m);
static_assert(!(321 * km < 123'000 * m));
static_assert(!(123 * km < 123'000 * m));
static_assert(!(321 * km <= 123'000 * m));
static_assert(!(123 * km > 321'000 * m));
static_assert(!(123 * km > 123'000 * m));
static_assert(!(123 * km >= 321'000 * m));
// dimensionless
static_assert(123 * one < 321);