From b221dace3ffe2ca7e8b93c94ee78aaedfe7df851 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 2 Apr 2022 21:36:42 +0200 Subject: [PATCH] style: clang-format applied to the remaining files --- example/aliases/avg_speed.cpp | 49 ++-- example/aliases/box_example.cpp | 15 +- example/aliases/capacitor_time_curve.cpp | 2 +- example/aliases/foot_pound_second.cpp | 57 +++- example/aliases/glide_computer_example.cpp | 37 +-- example/aliases/linear_algebra.cpp | 72 ++--- example/aliases/measurement.cpp | 3 +- example/aliases/total_energy.cpp | 12 +- example/aliases/unknown_dimension.cpp | 15 +- example/conversion_factor.cpp | 5 +- example/custom_systems.cpp | 5 +- example/glide_computer/geographic.cpp | 3 +- example/glide_computer/glide_computer.cpp | 32 +- example/glide_computer/include/geographic.h | 1 - .../glide_computer/include/glide_computer.h | 26 +- example/hello_units.cpp | 23 +- example/kalman_filter/kalman.h | 67 +++-- .../kalman_filter/kalman_filter-example_1.cpp | 16 +- .../kalman_filter/kalman_filter-example_2.cpp | 12 +- .../kalman_filter/kalman_filter-example_3.cpp | 12 +- .../kalman_filter/kalman_filter-example_4.cpp | 15 +- .../kalman_filter/kalman_filter-example_5.cpp | 18 +- .../kalman_filter/kalman_filter-example_6.cpp | 33 +-- .../kalman_filter/kalman_filter-example_7.cpp | 33 +-- .../kalman_filter/kalman_filter-example_8.cpp | 33 +-- example/literals/avg_speed.cpp | 53 ++-- example/literals/box_example.cpp | 13 +- example/literals/capacitor_time_curve.cpp | 2 +- example/literals/foot_pound_second.cpp | 63 +++- example/literals/glide_computer_example.cpp | 37 +-- example/literals/linear_algebra.cpp | 72 ++--- example/literals/total_energy.cpp | 12 +- example/literals/unknown_dimension.cpp | 15 +- example/measurement.cpp | 6 +- example/references/avg_speed.cpp | 49 ++-- example/references/box_example.cpp | 13 +- example/references/capacitor_time_curve.cpp | 2 +- example/references/clcpp_response.cpp | 12 +- example/references/experimental_angle.cpp | 6 +- example/references/foot_pound_second.cpp | 65 ++++- example/references/glide_computer_example.cpp | 37 +-- example/references/linear_algebra.cpp | 72 ++--- example/references/total_energy.cpp | 10 +- example/references/unknown_dimension.cpp | 15 +- src/core/include/units/generic/angle.h | 10 +- .../include/units/isq/si/fps/acceleration.h | 13 +- .../si-fps/include/units/isq/si/fps/area.h | 17 +- .../si-fps/include/units/isq/si/fps/density.h | 15 +- .../si-fps/include/units/isq/si/fps/energy.h | 24 +- .../si-fps/include/units/isq/si/fps/force.h | 33 ++- .../si-fps/include/units/isq/si/fps/fps.h | 7 +- .../include/units/isq/si/fps/pressure.h | 40 ++- .../si-fps/include/units/isq/si/fps/speed.h | 37 ++- .../si-hep/include/units/isq/si/hep/area.h | 63 +++- .../include/units/isq/si/international/area.h | 15 +- .../isq/si/international/international.h | 3 +- .../si/include/units/isq/si/absorbed_dose.h | 195 ++++++++++--- .../si/include/units/isq/si/acceleration.h | 13 +- .../units/isq/si/amount_of_substance.h | 15 +- .../include/units/isq/si/angular_velocity.h | 16 +- src/systems/si/include/units/isq/si/area.h | 204 ++++++++++--- .../si/include/units/isq/si/capacitance.h | 197 ++++++++++--- .../si/include/units/isq/si/concentration.h | 18 +- .../si/include/units/isq/si/conductance.h | 161 +++++++--- src/systems/si/include/units/isq/si/density.h | 15 +- src/systems/si/include/units/isq/si/energy.h | 180 +++++++++--- src/systems/si/include/units/isq/si/force.h | 195 ++++++++++--- .../si/include/units/isq/si/luminance.h | 13 +- .../include/units/isq/si/luminous_intensity.h | 195 ++++++++++--- .../si/include/units/isq/si/molar_energy.h | 18 +- .../si/include/units/isq/si/pressure.h | 195 ++++++++++--- .../si/include/units/isq/si/radioactivity.h | 195 ++++++++++--- src/systems/si/include/units/isq/si/voltage.h | 195 ++++++++++--- test/metabench/list/type_list_concepts_all.h | 229 ++++++++------- .../metabench/list/type_list_concepts_iface.h | 251 ++++++++-------- test/metabench/list/type_list_concepts_no.h | 235 +++++++-------- .../list/type_list_conditional_alias.h | 251 ++++++++-------- .../list/type_list_conditional_alias_hard.h | 242 ++++++++-------- .../list/type_list_conditional_std.h | 223 +++++++------- .../make_dimension/dimension_concepts_all.h | 259 ++++++++--------- .../make_dimension/dimension_concepts_iface.h | 259 ++++++++--------- .../make_dimension/dimension_no_concepts.h | 221 +++++++------- .../make_dimension/downcasting_concepts_all.h | 29 +- .../make_dimension/downcasting_no_concepts.h | 20 +- test/metabench/make_dimension/hacks.h | 14 +- .../make_dimension/ratio_concepts_all.h | 153 +++++----- .../make_dimension/ratio_concepts_iface.h | 153 +++++----- .../make_dimension/ratio_no_concepts.h | 135 ++++----- .../make_dimension/type_list_concepts_all.h | 223 +++++++------- .../make_dimension/type_list_concepts_iface.h | 223 +++++++------- .../make_dimension/type_list_no_concepts.h | 207 ++++++------- test/metabench/make_dimension/type_traits.h | 30 +- test/metabench/ratio/ratio_type_constexpr.h | 140 ++++----- test/metabench/ratio/std_ratio.h | 49 ++-- .../static/dimensions_concepts_test.cpp | 11 +- test/unit_test/static/fixed_string_test.cpp | 2 +- test/unit_test/static/fps_test.cpp | 5 +- test/unit_test/static/quantity_kind_test.cpp | 2 +- test/unit_test/static/quantity_point_test.cpp | 164 ++++++----- test/unit_test/static/quantity_test.cpp | 274 +++++++++++------- test/unit_test/static/ratio_test.cpp | 2 +- test/unit_test/static/references_test.cpp | 39 +-- test/unit_test/static/si_cgs_test.cpp | 43 +-- test/unit_test/static/si_fps_test.cpp | 84 +++--- test/unit_test/static/si_hep_test.cpp | 12 +- test/unit_test/static/si_test.cpp | 13 +- test/unit_test/static/symbol_text_test.cpp | 2 +- test/unit_test/static/type_list_test.cpp | 29 +- test/unit_test/static/unit_test.cpp | 11 +- 109 files changed, 4546 insertions(+), 3140 deletions(-) diff --git a/example/aliases/avg_speed.cpp b/example/aliases/avg_speed.cpp index e9b2272b..d09b2571 100644 --- a/example/aliases/avg_speed.cpp +++ b/example/aliases/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -169,7 +165,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -178,20 +176,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/aliases/box_example.cpp b/example/aliases/box_example.cpp index 869c337d..048cdb46 100644 --- a/example/aliases/box_example.cpp +++ b/example/aliases/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -40,7 +40,7 @@ namespace { using namespace units::aliases::isq::si; -inline constexpr auto g = units::isq::si::si2019::standard_gravity<>; +inline constexpr auto g = units::isq::si::si2019::standard_gravity<>; // NOLINT(readability-identifier-length) inline constexpr auto air_density = kg_per_m3<>(1.225); class Box { @@ -48,7 +48,10 @@ class Box { length::m<> height_; density::kg_per_m3<> density_ = air_density; public: - constexpr Box(const length::m<>& length, const length::m<>& width, length::m<> height): base_(length * width), height_(std::move(height)) {} + constexpr Box(const length::m<>& length, const length::m<>& width, length::m<> height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr force::N<> filled_weight() const { @@ -86,13 +89,13 @@ int main() auto box = Box(mm<>(1000.0), mm<>(500.0), height); box.set_contents_density(kg_per_m3<>(1000.0)); - const auto fill_time = s<>(200.0); // time since starting fill - const auto measured_mass = kg<>(20.0); // measured mass at fill_time + const auto fill_time = s<>(200.0); // time since starting fill + const auto measured_mass = kg<>(20.0); // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/aliases/capacitor_time_curve.cpp b/example/aliases/capacitor_time_curve.cpp index fc2eeff9..ab20cf78 100644 --- a/example/aliases/capacitor_time_curve.cpp +++ b/example/aliases/capacitor_time_curve.cpp @@ -25,7 +25,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp index 3b2dcab5..588e328d 100644 --- a/example/aliases/foot_pound_second.cpp +++ b/example/aliases/foot_pound_second.cpp @@ -52,7 +52,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -63,16 +63,21 @@ void print_details(std::string_view description, const Ship& ship) { const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4); std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed::km_per_h<>>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length::mm<>>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing",fmt_line, si::mass::kg<>>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at",fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume::l<>>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed::km_per_h<>>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length::mm<>>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass::kg<>>(ship.shellMass)) + << STD_FMT::format("{:20} : {}\n", "fire shells at", + fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume::l<>>(ship.mass / waterDensity)); } int main() @@ -82,13 +87,37 @@ int main() using units::aliases::isq::si::fps::length::ft; // to disambiguate from si::femptotonne // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{m<>(251.)}, .draft{m<>(9.3)}, .beam{m<>(36)}, .speed{km_per_h<>(56)}, .mass{t<>(50'300)}, .mainGuns{mm<>(380)}, .shellMass{kg<>(800)}, .shellSpeed{m_per_s<>(820.)}, .power{kW<>(110.45)}}; + auto bismark = Ship{.length{m<>(251.)}, + .draft{m<>(9.3)}, + .beam{m<>(36)}, + .speed{km_per_h<>(56)}, + .mass{t<>(50'300)}, + .mainGuns{mm<>(380)}, + .shellMass{kg<>(800)}, + .shellSpeed{m_per_s<>(820.)}, + .power{kW<>(110.45)}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{ft<>(860.)}, .draft{ft<>(37.) + in<>(2.)}, .beam{ft<>(108.) + in<>(2.)}, .speed{knot<>(33)}, .mass{lton<>(57'540)}, .mainGuns{in<>(16)}, .shellMass{lb<>(2700)}, .shellSpeed{ft_per_s<>(2690.)}, .power{hp<>(212'000)}}; + auto iowa = Ship{.length{ft<>(860.)}, + .draft{ft<>(37.) + in<>(2.)}, + .beam{ft<>(108.) + in<>(2.)}, + .speed{knot<>(33)}, + .mass{lton<>(57'540)}, + .mainGuns{in<>(16)}, + .shellMass{lb<>(2700)}, + .shellSpeed{ft_per_s<>(2690.)}, + .power{hp<>(212'000)}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{ft<>(745.1)}, .draft{ft<>(33.) + in<>(7.5)}, .beam{ft<>(103.2) + in<>(2.5)}, .speed{knot<>(28.3)}, .mass{lton<>(42'245)}, .mainGuns{in<>(14)}, .shellMass{lb<>(1'590)}, .shellSpeed{ft_per_s<>(2483)}, .power{hp<>(110'000)}}; + auto kgv = Ship{.length{ft<>(745.1)}, + .draft{ft<>(33.) + in<>(7.5)}, + .beam{ft<>(103.2) + in<>(2.5)}, + .speed{knot<>(28.3)}, + .mass{lton<>(42'245)}, + .mainGuns{in<>(14)}, + .shellMass{lb<>(1'590)}, + .shellSpeed{ft_per_s<>(2483)}, + .power{hp<>(110'000)}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/aliases/glide_computer_example.cpp b/example/aliases/glide_computer_example.cpp index 11d40e6e..0be12c1c 100644 --- a/example/aliases/glide_computer_example.cpp +++ b/example/aliases/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace units::aliases::isq::si; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(km_per_h<>(83)), rate_of_climb(m_per_s<>(-0.7389))}}, - glider{"SZD-51 Junior", {velocity(km_per_h<>(80)), rate_of_climb(m_per_s<>(-0.6349))}}, - glider{"SZD-48 Jantar Std 3", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.77355))}}, - glider{"SZD-56 Diana", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.63657))}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(km_per_h<>(83)), rate_of_climb(m_per_s<>(-0.7389))}}, + glider{"SZD-51 Junior", {velocity(km_per_h<>(80)), rate_of_climb(m_per_s<>(-0.6349))}}, + glider{"SZD-48 Jantar Std 3", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.77355))}}, + glider{"SZD-56 Diana", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.63657))}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace units::aliases::isq::si; static const std::array weather_conditions = { - std::pair("Good", weather{height(m<>(1900)), rate_of_climb(m_per_s<>(4.3))}), - std::pair("Medium", weather{height(m<>(1550)), rate_of_climb(m_per_s<>(2.8))}), - std::pair("Bad", weather{height(m<>(850)), rate_of_climb(m_per_s<>(1.8))})}; + std::pair("Good", weather{height(m<>(1900)), rate_of_climb(m_per_s<>(4.3))}), + std::pair("Medium", weather{height(m<>(1550)), rate_of_climb(m_per_s<>(2.8))}), + std::pair("Bad", weather{height(m<>(850)), rate_of_climb(m_per_s<>(1.8))})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::aliases::isq::si::international; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(ft<>(16))}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(ft<>(115))} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(ft<>(16))}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(ft<>(115))} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/aliases/linear_algebra.cpp b/example/aliases/linear_algebra.cpp index 79ef9f52..b624ad3e 100644 --- a/example/aliases/linear_algebra.cpp +++ b/example/aliases/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -72,9 +72,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { m<>(1), m<>(2), m<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; - vector> t = { km<>(3), km<>(2), km<>(1) }; + vector> v = {m<>(1), m<>(2), m<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; + vector> t = {km<>(3), km<>(2), km<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -89,8 +89,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { m<>(1), m<>(2), m<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; + vector> v = {m<>(1), m<>(2), m<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -103,8 +103,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { N<>(1), N<>(2), N<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; + vector> v = {N<>(1), N<>(2), N<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -118,7 +118,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { m<>(4), m<>(8), m<>(12) }; + vector> v = {m<>(4), m<>(8), m<>(12)}; std::cout << "v = " << v << "\n"; @@ -139,9 +139,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; - matrix> u = {{ m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }}; - matrix> t = {{ mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }}; + matrix> v = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; + matrix> u = {{m<>(3), m<>(2), m<>(1)}, {m<>(3), m<>(2), m<>(1)}, {m<>(3), m<>(2), m<>(1)}}; + matrix> t = {{mm<>(3), mm<>(2), mm<>(1)}, {mm<>(3), mm<>(2), mm<>(1)}, {mm<>(3), mm<>(2), mm<>(1)}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -158,8 +158,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; - vector> u = { m<>(3), m<>(2), m<>(1) }; + matrix> v = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -172,8 +172,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { N<>(1), N<>(2), N<>(3) }; - matrix> u = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; + vector> v = {N<>(1), N<>(2), N<>(3)}; + matrix> u = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -187,7 +187,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ m<>(2), m<>(4), m<>(6) }, { m<>(4), m<>(6), m<>(8) }, { m<>(8), m<>(4), m<>(2) }}; + matrix> v = {{m<>(2), m<>(4), m<>(6)}, {m<>(4), m<>(6), m<>(8)}, {m<>(8), m<>(4), m<>(2)}}; std::cout << "v =\n" << v << "\n"; @@ -216,9 +216,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -233,8 +233,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -247,8 +247,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -262,7 +262,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -286,9 +286,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -305,8 +305,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -319,8 +319,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -334,7 +334,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/aliases/measurement.cpp b/example/aliases/measurement.cpp index ff91d62b..c952387b 100644 --- a/example/aliases/measurement.cpp +++ b/example/aliases/measurement.cpp @@ -38,8 +38,7 @@ public: measurement() = default; - constexpr explicit measurement(const value_type& val, const value_type& err = {}) : - value_(val) + constexpr explicit measurement(const value_type& val, const value_type& err = {}) : value_(val) { // it sucks that using declaration cannot be provided for a constructor initializer list using namespace std; diff --git a/example/aliases/total_energy.cpp b/example/aliases/total_energy.cpp index 693b47e4..0ad4c132 100644 --- a/example/aliases/total_energy.cpp +++ b/example/aliases/total_energy.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include +#include #include #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include #include #include @@ -85,18 +85,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/aliases/unknown_dimension.cpp b/example/aliases/unknown_dimension.cpp index 42df205e..5256abe8 100644 --- a/example/aliases/unknown_dimension.cpp +++ b/example/aliases/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = s<>(10); Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * m<>(50); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / m<>(100); // back to known dimensions again + auto temp1 = + v1 * m<>(50); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / m<>(100); // back to known dimensions again Length auto d2 = v2 * s<>(60); std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 665b16e2..0858e954 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -54,7 +54,8 @@ int main() std::cout << STD_FMT::format("therefore ratio lengthA / lengthB == {}\n\n", lengthA / lengthB); - std::cout << STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", lengthA, lengthB) + std::cout << STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", lengthA, + lengthB) << STD_FMT::format("lengthB.number( {} ) == lengthA.number( {} ) * conversion_factor( {} )\n", - lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); + lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); } diff --git a/example/custom_systems.cpp b/example/custom_systems.cpp index f3264aed..f8dfd28f 100644 --- a/example/custom_systems.cpp +++ b/example/custom_systems.cpp @@ -66,10 +66,7 @@ using length = quantity; } // namespace si template -concept castable_to = Quantity && Unit && - requires (Q q) { - quantity_cast(q); - }; +concept castable_to = Quantity && Unit && requires(Q q) { quantity_cast(q); }; void conversions() { diff --git a/example/glide_computer/geographic.cpp b/example/glide_computer/geographic.cpp index 5d6073b3..4150c792 100644 --- a/example/glide_computer/geographic.cpp +++ b/example/glide_computer/geographic.cpp @@ -49,7 +49,8 @@ distance spherical_distance(position from, position to) if constexpr (sizeof(rep) >= 8) { // spherical law of cosines const auto central_angle = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)); - // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2 - lat1) / 2 + cos(lat1) * cos(lat2) * (1 - cos(lon2 - lon1)) / 2)); + // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2 - lat1) / 2 + cos(lat1) * cos(lat2) * (1 - cos(lon2 - + // lon1)) / 2)); return distance(earth_radius * central_angle); } else { // the haversine formula diff --git a/example/glide_computer/glide_computer.cpp b/example/glide_computer/glide_computer.cpp index 79d325c1..fe7b7d62 100644 --- a/example/glide_computer/glide_computer.cpp +++ b/example/glide_computer/glide_computer.cpp @@ -34,7 +34,8 @@ task::legs task::make_legs(const waypoints& wpts) task::legs res; res.reserve(wpts.size() - 1); auto to_leg = [](const waypoint& w1, const waypoint& w2) { return task::leg(w1, w2); }; - std::ranges::transform(wpts.cbegin(), prev(wpts.cend()), next(wpts.cbegin()), wpts.cend(), std::back_inserter(res), to_leg); + std::ranges::transform(wpts.cbegin(), prev(wpts.cend()), next(wpts.cbegin()), wpts.cend(), std::back_inserter(res), + to_leg); return res; } @@ -64,24 +65,23 @@ distance glide_distance(const flight_point& pos, const glider& g, const task& t, ((ground_alt - t.get_finish().alt) / dist_to_finish - 1 / glide_ratio(g.polar[0]))); } -} +} // namespace glide_computer namespace { using namespace glide_computer; -void print(std::string_view phase_name, timestamp start_ts, const glide_computer::flight_point& point, const glide_computer::flight_point& new_point) +void print(std::string_view phase_name, timestamp start_ts, const glide_computer::flight_point& point, + const glide_computer::flight_point& new_point) { std::cout << STD_FMT::format( - "| {:<12} | {:>9%.1Q %q} (Total: {:>9%.1Q %q}) | {:>8%.1Q %q} (Total: {:>8%.1Q %q}) | {:>7%.0Q %q} ({:>6%.0Q %q}) |\n", - phase_name, quantity_cast(new_point.ts - point.ts), quantity_cast(new_point.ts - start_ts), - new_point.dist - point.dist, new_point.dist, new_point.alt - point.alt, new_point.alt); + "| {:<12} | {:>9%.1Q %q} (Total: {:>9%.1Q %q}) | {:>8%.1Q %q} (Total: {:>8%.1Q %q}) | {:>7%.0Q %q} ({:>6%.0Q %q}) " + "|\n", + phase_name, quantity_cast(new_point.ts - point.ts), quantity_cast(new_point.ts - start_ts), + new_point.dist - point.dist, new_point.dist, new_point.alt - point.alt, new_point.alt); } -flight_point takeoff(timestamp start_ts, const task& t) -{ - return {start_ts, t.get_start().alt}; -} +flight_point takeoff(timestamp start_ts, const task& t) { return {start_ts, t.get_start().alt}; } flight_point tow(timestamp start_ts, const flight_point& pos, const aircraft_tow& at) { @@ -92,7 +92,8 @@ flight_point tow(timestamp start_ts, const flight_point& pos, const aircraft_tow return new_pos; } -flight_point circle(timestamp start_ts, const flight_point& pos, const glider& g, const weather& w, const task& t, height& height_to_gain) +flight_point circle(timestamp start_ts, const flight_point& pos, const glider& g, const weather& w, const task& t, + height& height_to_gain) { const height h_agl = agl(pos.alt, terrain_level_alt(t, pos)); const height circling_height = std::min(w.cloud_base - h_agl, height_to_gain); @@ -114,7 +115,8 @@ flight_point glide(timestamp start_ts, const flight_point& pos, const glider& g, const auto alt = ground_alt + s.min_agl_height; const auto l3d = length_3d(dist, pos.alt - alt); const duration d = l3d / g.polar[0].v.common(); - const flight_point new_pos{pos.ts + d, terrain_level_alt(t, pos) + s.min_agl_height, t.get_leg_index(new_distance), new_distance}; + const flight_point new_pos{pos.ts + d, terrain_level_alt(t, pos) + s.min_agl_height, t.get_leg_index(new_distance), + new_distance}; print("Glide", start_ts, pos, new_pos); return new_pos; @@ -135,9 +137,11 @@ flight_point final_glide(timestamp start_ts, const flight_point& pos, const glid namespace glide_computer { -void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, const aircraft_tow& at) +void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, + const aircraft_tow& at) { - std::cout << STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance", "Height"); + std::cout << STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance", + "Height"); std::cout << STD_FMT::format("|{0:-^14}|{0:-^30}|{0:-^28}|{0:-^23}|\n", ""); // ready to takeoff diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index 5deb1b1c..44290080 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -25,7 +25,6 @@ #include #include #include - #include #include diff --git a/example/glide_computer/include/glide_computer.h b/example/glide_computer/include/glide_computer.h index 7202005a..d545ea7a 100644 --- a/example/glide_computer/include/glide_computer.h +++ b/example/glide_computer/include/glide_computer.h @@ -32,14 +32,14 @@ #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include // An example of a really simplified tactical glide computer @@ -69,7 +69,7 @@ namespace glide_computer { template constexpr units::Dimensionless auto operator/(const QK1& lhs, const QK2& rhs) - requires(!units::QuantityKindRelatedTo) && requires { lhs.common() / rhs.common();} + requires(!units::QuantityKindRelatedTo) && requires { lhs.common() / rhs.common(); } { return lhs.common() / rhs.common(); } @@ -149,7 +149,7 @@ public: const waypoint* end_; distance length_ = geographic::spherical_distance(begin().pos, end().pos); public: - leg(const waypoint& b, const waypoint& e) noexcept: begin_(&b), end_(&e) {} + leg(const waypoint& b, const waypoint& e) noexcept : begin_(&b), end_(&e) {} constexpr const waypoint& begin() const { return *begin_; }; constexpr const waypoint& end() const { return *end_; } constexpr const distance get_length() const { return length_; } @@ -157,8 +157,11 @@ public: using legs = std::vector; template - requires std::same_as, waypoint> - explicit task(const R& r) : waypoints_(std::ranges::begin(r), std::ranges::end(r)) {} + requires std::same_as, + waypoint> explicit task(const R& r) : + waypoints_(std::ranges::begin(r), std::ranges::end(r)) + { + } task(std::initializer_list wpts) : waypoints_(wpts) {} @@ -170,10 +173,14 @@ public: distance get_length() const { return length_; } - distance get_leg_dist_offset(std::size_t leg_index) const { return leg_index == 0 ? distance{} : leg_total_distances_[leg_index - 1]; } + distance get_leg_dist_offset(std::size_t leg_index) const + { + return leg_index == 0 ? distance{} : leg_total_distances_[leg_index - 1]; + } std::size_t get_leg_index(distance dist) const { - return static_cast(std::ranges::distance(leg_total_distances_.cbegin(), std::ranges::lower_bound(leg_total_distances_, dist))); + return static_cast( + std::ranges::distance(leg_total_distances_.cbegin(), std::ranges::lower_bound(leg_total_distances_, dist))); } private: @@ -214,6 +221,7 @@ inline units::isq::si::length length_3d(distance dist distance glide_distance(const flight_point& pos, const glider& g, const task& t, const safety& s, altitude ground_alt); -void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, const aircraft_tow& at); +void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, + const aircraft_tow& at); } // namespace glide_computer diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 6b339036..5bfbc860 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -22,19 +22,16 @@ #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include using namespace units::isq; -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } int main() { @@ -55,11 +52,11 @@ int main() #endif constexpr Speed auto v7 = quantity_cast(v6); - std::cout << v1 << '\n'; // 110 km/h - std::cout << v2 << '\n'; // 70 mi/h - std::cout << STD_FMT::format("{}", v3) << '\n'; // 110 km/h - std::cout << STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** - std::cout << STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s - std::cout << STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s - std::cout << STD_FMT::format("{:%Q}", v7) << '\n'; // 31 + std::cout << v1 << '\n'; // 110 km/h + std::cout << v2 << '\n'; // 70 mi/h + std::cout << STD_FMT::format("{}", v3) << '\n'; // 110 km/h + std::cout << STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** + std::cout << STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s + std::cout << STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s + std::cout << STD_FMT::format("{:%Q}", v7) << '\n'; // 31 } diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index 46b0354f..16a21375 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -34,7 +34,8 @@ namespace kalman { template -concept QuantityOrQuantityPoint = units::Quantity || units::QuantityPoint; // TODO Should it also account for `kinds`? +concept QuantityOrQuantityPoint = + units::Quantity || units::QuantityPoint; // TODO Should it also account for `kinds`? template inline constexpr bool are_derivatives = false; @@ -44,34 +45,42 @@ inline constexpr bool are_derivatives = true; template inline constexpr bool are_derivatives = - units::DimensionOfT && // TODO Think on how to simplify this + units::DimensionOfT && // TODO Think on how to simplify this are_derivatives; // state template - requires (sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives + requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives struct state { std::tuple variables_; - constexpr state(QQPs... qqps): variables_(std::move(qqps)...) {} + constexpr state(QQPs... qqps) : variables_(std::move(qqps)...) {} }; template concept State = units::is_specialization_of; template -constexpr auto& get(state& s) { return get(s.variables_); } +constexpr auto& get(state& s) +{ + return get(s.variables_); +} template -constexpr const auto& get(const state& s) { return get(s.variables_); } +constexpr const auto& get(const state& s) +{ + return get(s.variables_); +} // estimation template struct estimation { private: using uncertainty_ref = decltype(QQP::reference * QQP::reference); - using uncertainty_type = units::quantity; + using uncertainty_type = + units::quantity; public: - kalman::state state; // TODO extend kalman functions to work with this variadic patermater list + kalman::state state; // TODO extend kalman functions to work with this variadic patermater list uncertainty_type uncertainty; }; @@ -94,7 +103,7 @@ template requires units::equivalent constexpr state state_update(const state& predicted, QM measured, K gain) { - return { get<0>(predicted) + gain * (measured - get<0>(predicted)) }; + return {get<0>(predicted) + gain * (measured - get<0>(predicted))}; } template @@ -103,17 +112,18 @@ constexpr state state_update(const state& predicted, QM measured { const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted)); const auto q2 = get<1>(predicted) + get<1>(gain) * (measured - get<0>(predicted)) / interval; - return { q1, q2 }; + return {q1, q2}; } template requires units::equivalent -constexpr state state_update(const state& predicted, QM measured, std::array gain, T interval) +constexpr state state_update(const state& predicted, QM measured, std::array gain, + T interval) { const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted)); const auto q2 = get<1>(predicted) + get<1>(gain) * (measured - get<0>(predicted)) / interval; const auto q3 = get<2>(predicted) + get<2>(gain) * (measured - get<0>(predicted)) / (interval * interval / 2); - return { q1, q2, q3 }; + return {q1, q2, q3}; } // covariance update @@ -129,7 +139,7 @@ constexpr state state_extrapolation(const state& estimated, T in { const auto q1 = get<0>(estimated) + get<1>(estimated) * interval; const auto q2 = get<1>(estimated); - return { q1, q2 }; + return {q1, q2}; } template @@ -138,7 +148,7 @@ constexpr state state_extrapolation(const state& estimat const auto q1 = get<0>(estimated) + get<1>(estimated) * interval + get<2>(estimated) * pow<2>(interval) / 2; const auto q2 = get<1>(estimated) + get<2>(estimated) * interval; const auto q3 = get<2>(estimated); - return { q1, q2, q3 }; + return {q1, q2, q3}; } // covariance extrapolation @@ -164,24 +174,26 @@ struct STD_FMT::formatter> { std::string value_buffer; auto to_value_buffer = std::back_inserter(value_buffer); if (specs.precision != -1) { - if constexpr(sizeof...(Qs) == 1) + if constexpr (sizeof...(Qs) == 1) STD_FMT::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s)); - else if constexpr(sizeof...(Qs) == 2) - STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s)); + else if constexpr (sizeof...(Qs) == 2) + STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), + kalman::get<1>(s)); else - STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); - } - else { - if constexpr(sizeof...(Qs) == 1) + STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, + kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); + } else { + if constexpr (sizeof...(Qs) == 1) STD_FMT::format_to(to_value_buffer, "{}", kalman::get<0>(s)); - else if constexpr(sizeof...(Qs) == 2) + else if constexpr (sizeof...(Qs) == 2) STD_FMT::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s)); else - STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); + STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), + kalman::get<2>(s)); } std::string global_format_buffer; - units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; + units::detail::quantity_global_format_specs global_specs = {specs.fill, specs.align, specs.width}; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); @@ -202,7 +214,7 @@ struct STD_FMT::formatter> { auto format(kalman::estimation e, FormatContext& ctx) { units::Quantity auto q = [](const Q& t) { - if constexpr(units::Quantity) + if constexpr (units::Quantity) return t; else return t.relative(); @@ -212,13 +224,12 @@ struct STD_FMT::formatter> { auto to_value_buffer = std::back_inserter(value_buffer); if (specs.precision != -1) { STD_FMT::format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), specs.precision); - } - else { + } else { STD_FMT::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty)); } std::string global_format_buffer; - units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; + units::detail::quantity_global_format_specs global_specs = {specs.fill, specs.align, specs.width}; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); diff --git a/example/kalman_filter/kalman_filter-example_1.cpp b/example/kalman_filter/kalman_filter-example_1.cpp index 91057277..efd624ae 100644 --- a/example/kalman_filter/kalman_filter-example_1.cpp +++ b/example/kalman_filter/kalman_filter-example_1.cpp @@ -21,9 +21,9 @@ // SOFTWARE. #include "kalman.h" -#include #include #include +#include #include #include @@ -34,10 +34,12 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } -void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next) +void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, + const kalman::State auto& next) { std::cout << STD_FMT::format("{:2} | {:9} | {:8} | {:14} | {:14}\n", iteration, gain, measured, current, next); } @@ -48,13 +50,13 @@ int main() using namespace units::isq::si::references; using state = kalman::state>; - const state initial = { 1 * kg }; - const std::array measurements = { 1030 * g, 989 * g, 1017 * g, 1009 * g, 1013 * g, - 979 * g, 1008 * g, 1042 * g, 1012 * g, 1011 * g }; + const state initial = {1 * kg}; + const std::array measurements = {1030 * g, 989 * g, 1017 * g, 1009 * g, 1013 * g, + 979 * g, 1008 * g, 1042 * g, 1012 * g, 1011 * g}; print_header(initial); state next = initial; - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const dimensionless gain = 1. / index; const auto current = state_update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_2.cpp b/example/kalman_filter/kalman_filter-example_2.cpp index 222bd165..23ea2bbf 100644 --- a/example/kalman_filter/kalman_filter-example_2.cpp +++ b/example/kalman_filter/kalman_filter-example_2.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include -#include -#include #include #include @@ -51,14 +51,14 @@ int main() using state = kalman::state, si::speed>; const auto interval = 5 * s; - const state initial = { 30 * km, 40 * (m / s) }; - const std::array measurements = { 30110 * m, 30265 * m, 30740 * m, 30750 * m, 31135 * m, - 31015 * m, 31180 * m, 31610 * m, 31960 * m, 31865 * m }; + const state initial = {30 * km, 40 * (m / s)}; + const std::array measurements = {30110 * m, 30265 * m, 30740 * m, 30750 * m, 31135 * m, + 31015 * m, 31180 * m, 31610 * m, 31960 * m, 31865 * m}; std::array gain = {dimensionless(0.2), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_3.cpp b/example/kalman_filter/kalman_filter-example_3.cpp index 7a7c0291..267e8a3d 100644 --- a/example/kalman_filter/kalman_filter-example_3.cpp +++ b/example/kalman_filter/kalman_filter-example_3.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include -#include -#include #include #include @@ -51,14 +51,14 @@ int main() using state = kalman::state, si::speed>; const auto interval = 5 * s; - const state initial = { 30 * km, 50 * (m / s) }; - const std::array measurements = { 30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, - 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m }; + const state initial = {30 * km, 50 * (m / s)}; + const std::array measurements = {30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, + 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m}; std::array gain = {dimensionless(0.2), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_4.cpp b/example/kalman_filter/kalman_filter-example_4.cpp index c6692b12..0ba7e36d 100644 --- a/example/kalman_filter/kalman_filter-example_4.cpp +++ b/example/kalman_filter/kalman_filter-example_4.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include #include -#include -#include #include #include @@ -49,19 +49,20 @@ int main() { using namespace units::isq; using namespace units::isq::si::references; - using state = kalman::state, si::speed, si::acceleration>; + using state = + kalman::state, si::speed, si::acceleration>; constexpr auto mps = m / s; constexpr auto mps2 = mps / s; const auto interval = 5. * s; - const state initial = { 30 * km, 50 * mps, 0 * mps2 }; - const std::array measurements = { 30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, - 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m }; + const state initial = {30 * km, 50 * mps, 0 * mps2}; + const std::array measurements = {30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, + 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m}; std::array gain = {dimensionless(0.5), dimensionless(0.4), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_5.cpp b/example/kalman_filter/kalman_filter-example_5.cpp index 47db0134..d68f9601 100644 --- a/example/kalman_filter/kalman_filter-example_5.cpp +++ b/example/kalman_filter/kalman_filter-example_5.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -35,13 +35,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, Q measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, next); + std::cout << STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, + next); } int main() @@ -50,20 +52,20 @@ int main() using namespace units::isq; using namespace units::isq::si::references; - const estimation initial = { state{ 60. * m }, pow<2>(15. * m) }; - const std::array measurements = { 48.54 * m, 47.11 * m, 55.01 * m, 55.15 * m, 49.89 * m, - 40.85 * m, 46.72 * m, 50.05 * m, 51.27 * m, 49.95 * m }; + const estimation initial = {state{60. * m}, pow<2>(15. * m)}; + const std::array measurements = {48.54 * m, 47.11 * m, 55.01 * m, 55.15 * m, 49.89 * m, + 40.85 * m, 46.72 * m, 50.05 * m, 51.27 * m, 49.95 * m}; const auto measurement_uncertainty = pow<2>(5. * m); auto update = [=](const estimation& previous, const Q& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [](const estimation& current) { return current; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, measured, gain); diff --git a/example/kalman_filter/kalman_filter-example_6.cpp b/example/kalman_filter/kalman_filter-example_6.cpp index e17045da..fac8c34b 100644 --- a/example/kalman_filter/kalman_filter-example_6.cpp +++ b/example/kalman_filter/kalman_filter-example_6.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.0001 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(49.95 * deg_C), - quantity_point(49.967 * deg_C), - quantity_point(50.1 * deg_C), - quantity_point(50.106 * deg_C), - quantity_point(49.992 * deg_C), - quantity_point(49.819 * deg_C), - quantity_point(49.933 * deg_C), - quantity_point(50.007 * deg_C), - quantity_point(50.023 * deg_C), - quantity_point(49.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(49.95 * deg_C), quantity_point(49.967 * deg_C), + quantity_point(50.1 * deg_C), quantity_point(50.106 * deg_C), + quantity_point(49.992 * deg_C), quantity_point(49.819 * deg_C), + quantity_point(49.933 * deg_C), quantity_point(50.007 * deg_C), + quantity_point(50.023 * deg_C), quantity_point(49.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_7.cpp b/example/kalman_filter/kalman_filter-example_7.cpp index 743a0916..42ce7025 100644 --- a/example/kalman_filter/kalman_filter-example_7.cpp +++ b/example/kalman_filter/kalman_filter-example_7.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.0001 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(50.45 * deg_C), - quantity_point(50.967 * deg_C), - quantity_point(51.6 * deg_C), - quantity_point(52.106 * deg_C), - quantity_point(52.492 * deg_C), - quantity_point(52.819 * deg_C), - quantity_point(53.433 * deg_C), - quantity_point(54.007 * deg_C), - quantity_point(54.523 * deg_C), - quantity_point(54.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(50.45 * deg_C), quantity_point(50.967 * deg_C), + quantity_point(51.6 * deg_C), quantity_point(52.106 * deg_C), + quantity_point(52.492 * deg_C), quantity_point(52.819 * deg_C), + quantity_point(53.433 * deg_C), quantity_point(54.007 * deg_C), + quantity_point(54.523 * deg_C), quantity_point(54.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_8.cpp b/example/kalman_filter/kalman_filter-example_8.cpp index 13f379f1..3b81ae70 100644 --- a/example/kalman_filter/kalman_filter-example_8.cpp +++ b/example/kalman_filter/kalman_filter-example_8.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.15 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(50.45 * deg_C), - quantity_point(50.967 * deg_C), - quantity_point(51.6 * deg_C), - quantity_point(52.106 * deg_C), - quantity_point(52.492 * deg_C), - quantity_point(52.819 * deg_C), - quantity_point(53.433 * deg_C), - quantity_point(54.007 * deg_C), - quantity_point(54.523 * deg_C), - quantity_point(54.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(50.45 * deg_C), quantity_point(50.967 * deg_C), + quantity_point(51.6 * deg_C), quantity_point(52.106 * deg_C), + quantity_point(52.492 * deg_C), quantity_point(52.819 * deg_C), + quantity_point(53.433 * deg_C), quantity_point(54.007 * deg_C), + quantity_point(54.523 * deg_C), quantity_point(54.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/literals/avg_speed.cpp b/example/literals/avg_speed.cpp index 2c13fae9..5a3f3e05 100644 --- a/example/literals/avg_speed.cpp +++ b/example/literals/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -141,7 +137,7 @@ void example() { using namespace units::isq::si::cgs::literals; constexpr auto distance = 22'000'000_q_cm; - constexpr si::cgs::time duration(2); // cannot use an SI literal here + constexpr si::cgs::time duration(2); // cannot use an SI literal here std::cout << "\nCGS units with 'int' as representation\n"; @@ -160,14 +156,16 @@ void example() { using namespace units::isq::si::cgs::literals; constexpr auto distance = 22'000'000._q_cm; - constexpr si::cgs::time duration(2); // cannot use an SI literal here + constexpr si::cgs::time duration(2); // cannot use an SI literal here std::cout << "\nCGS units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -176,20 +174,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/literals/box_example.cpp b/example/literals/box_example.cpp index a736f6bd..7716d787 100644 --- a/example/literals/box_example.cpp +++ b/example/literals/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -56,7 +56,10 @@ class Box { si::length height_; si::density density_ = air_density; public: - constexpr Box(const si::length& length, const si::length& width, si::length height) : base_(length * width), height_(std::move(height)) {} + constexpr Box(const si::length& length, const si::length& width, si::length height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr si::force filled_weight() const { @@ -94,13 +97,13 @@ int main() auto box = Box(1000.0_q_mm, 500.0_q_mm, height); box.set_contents_density(1000.0_q_kg_per_m3); - const auto fill_time = 200.0_q_s; // time since starting fill - const auto measured_mass = 20.0_q_kg; // measured mass at fill_time + const auto fill_time = 200.0_q_s; // time since starting fill + const auto measured_mass = 20.0_q_kg; // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/literals/capacitor_time_curve.cpp b/example/literals/capacitor_time_curve.cpp index e1300e91..e844f359 100644 --- a/example/literals/capacitor_time_curve.cpp +++ b/example/literals/capacitor_time_curve.cpp @@ -26,7 +26,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/literals/foot_pound_second.cpp b/example/literals/foot_pound_second.cpp index 317b127c..69df4f51 100644 --- a/example/literals/foot_pound_second.cpp +++ b/example/literals/foot_pound_second.cpp @@ -53,7 +53,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -65,16 +65,27 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::literals; const auto waterDensity = 62.4_q_lb_per_ft3; std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing",fmt_line, si::mass>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at",fmt_line, si::speed>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() @@ -83,13 +94,37 @@ int main() using namespace units::isq::si::fps::literals; // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{251._q_m}, .draft{9.3_q_m}, .beam{36_q_m}, .speed{56_q_km_per_h}, .mass{50'300_q_t}, .mainGuns{380_q_mm}, .shellMass{800_q_kg}, .shellSpeed{820._q_m_per_s}, .power{110.45_q_kW}}; + auto bismark = Ship{.length{251._q_m}, + .draft{9.3_q_m}, + .beam{36_q_m}, + .speed{56_q_km_per_h}, + .mass{50'300_q_t}, + .mainGuns{380_q_mm}, + .shellMass{800_q_kg}, + .shellSpeed{820._q_m_per_s}, + .power{110.45_q_kW}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{860._q_ft}, .draft{37._q_ft + 2._q_in}, .beam{108._q_ft + 2._q_in}, .speed{33_q_knot}, .mass{57'540_q_lton}, .mainGuns{16_q_in}, .shellMass{2700_q_lb}, .shellSpeed{2690._q_ft_per_s}, .power{212'000_q_hp}}; + auto iowa = Ship{.length{860._q_ft}, + .draft{37._q_ft + 2._q_in}, + .beam{108._q_ft + 2._q_in}, + .speed{33_q_knot}, + .mass{57'540_q_lton}, + .mainGuns{16_q_in}, + .shellMass{2700_q_lb}, + .shellSpeed{2690._q_ft_per_s}, + .power{212'000_q_hp}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{745.1_q_ft}, .draft{33._q_ft + 7.5_q_in}, .beam{103.2_q_ft + 2.5_q_in}, .speed{28.3_q_knot}, .mass{42'245_q_lton}, .mainGuns{14_q_in}, .shellMass{1'590_q_lb}, .shellSpeed{2483._q_ft_per_s}, .power{110'000_q_hp}}; + auto kgv = Ship{.length{745.1_q_ft}, + .draft{33._q_ft + 7.5_q_in}, + .beam{103.2_q_ft + 2.5_q_in}, + .speed{28.3_q_knot}, + .mass{42'245_q_lton}, + .mainGuns{14_q_in}, + .shellMass{1'590_q_lb}, + .shellSpeed{2483._q_ft_per_s}, + .power{110'000_q_hp}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/literals/glide_computer_example.cpp b/example/literals/glide_computer_example.cpp index f3a2a832..60bf096a 100644 --- a/example/literals/glide_computer_example.cpp +++ b/example/literals/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace si::literals; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(83_q_km_per_h), rate_of_climb(-0.7389_q_m_per_s)}}, - glider{"SZD-51 Junior", {velocity(80_q_km_per_h), rate_of_climb(-0.6349_q_m_per_s)}}, - glider{"SZD-48 Jantar Std 3", {velocity(110_q_km_per_h), rate_of_climb(-0.77355_q_m_per_s)}}, - glider{"SZD-56 Diana", {velocity(110_q_km_per_h), rate_of_climb(-0.63657_q_m_per_s)}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(83_q_km_per_h), rate_of_climb(-0.7389_q_m_per_s)}}, + glider{"SZD-51 Junior", {velocity(80_q_km_per_h), rate_of_climb(-0.6349_q_m_per_s)}}, + glider{"SZD-48 Jantar Std 3", {velocity(110_q_km_per_h), rate_of_climb(-0.77355_q_m_per_s)}}, + glider{"SZD-56 Diana", {velocity(110_q_km_per_h), rate_of_climb(-0.63657_q_m_per_s)}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace si::literals; static const std::array weather_conditions = { - std::pair("Good", weather{height(1900_q_m), rate_of_climb(4.3_q_m_per_s)}), - std::pair("Medium", weather{height(1550_q_m), rate_of_climb(2.8_q_m_per_s)}), - std::pair("Bad", weather{height(850_q_m), rate_of_climb(1.8_q_m_per_s)})}; + std::pair("Good", weather{height(1900_q_m), rate_of_climb(4.3_q_m_per_s)}), + std::pair("Medium", weather{height(1550_q_m), rate_of_climb(2.8_q_m_per_s)}), + std::pair("Bad", weather{height(850_q_m), rate_of_climb(1.8_q_m_per_s)})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::isq::si::international::literals; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16_q_ft)}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115_q_ft)} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16_q_ft)}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115_q_ft)} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/literals/linear_algebra.cpp b/example/literals/linear_algebra.cpp index e10823c8..44201578 100644 --- a/example/literals/linear_algebra.cpp +++ b/example/literals/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -73,9 +73,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { 1_q_m, 2_q_m, 3_q_m }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; - vector> t = { 3_q_km, 2_q_km, 1_q_km }; + vector> v = {1_q_m, 2_q_m, 3_q_m}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; + vector> t = {3_q_km, 2_q_km, 1_q_km}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -90,8 +90,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { 1_q_m, 2_q_m, 3_q_m }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + vector> v = {1_q_m, 2_q_m, 3_q_m}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -104,8 +104,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { 1_q_N, 2_q_N, 3_q_N }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + vector> v = {1_q_N, 2_q_N, 3_q_N}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -119,7 +119,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { 4_q_m, 8_q_m, 12_q_m }; + vector> v = {4_q_m, 8_q_m, 12_q_m}; std::cout << "v = " << v << "\n"; @@ -140,9 +140,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; - matrix> u = {{ 3_q_m, 2_q_m, 1_q_m }, { 3_q_m, 2_q_m, 1_q_m }, { 3_q_m, 2_q_m, 1_q_m }}; - matrix> t = {{ 3_q_mm, 2_q_mm, 1_q_mm }, { 3_q_mm, 2_q_mm, 1_q_mm }, { 3_q_mm, 2_q_mm, 1_q_mm }}; + matrix> v = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; + matrix> u = {{3_q_m, 2_q_m, 1_q_m}, {3_q_m, 2_q_m, 1_q_m}, {3_q_m, 2_q_m, 1_q_m}}; + matrix> t = {{3_q_mm, 2_q_mm, 1_q_mm}, {3_q_mm, 2_q_mm, 1_q_mm}, {3_q_mm, 2_q_mm, 1_q_mm}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -159,8 +159,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + matrix> v = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -173,8 +173,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { 1_q_N, 2_q_N, 3_q_N }; - matrix> u = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; + vector> v = {1_q_N, 2_q_N, 3_q_N}; + matrix> u = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -188,7 +188,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ 2_q_m, 4_q_m, 6_q_m }, { 4_q_m, 6_q_m, 8_q_m }, { 8_q_m, 4_q_m, 2_q_m }}; + matrix> v = {{2_q_m, 4_q_m, 6_q_m}, {4_q_m, 6_q_m, 8_q_m}, {8_q_m, 4_q_m, 2_q_m}}; std::cout << "v =\n" << v << "\n"; @@ -215,9 +215,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -232,8 +232,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -246,8 +246,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -261,7 +261,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -285,9 +285,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -304,8 +304,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -318,8 +318,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -333,7 +333,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/literals/total_energy.cpp b/example/literals/total_energy.cpp index a81dd789..0cda3706 100644 --- a/example/literals/total_energy.cpp +++ b/example/literals/total_energy.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include +#include #include #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include #include #include @@ -88,18 +88,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/literals/unknown_dimension.cpp b/example/literals/unknown_dimension.cpp index aed204d8..fd26ee92 100644 --- a/example/literals/unknown_dimension.cpp +++ b/example/literals/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = 10_q_s; Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * 50_q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / 100_q_m; // back to known dimensions again + auto temp1 = + v1 * 50_q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / 100_q_m; // back to known dimensions again Length auto d2 = v2 * 60_q_s; std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/measurement.cpp b/example/measurement.cpp index 293a8c9f..ca7df2f3 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -38,8 +38,7 @@ public: measurement() = default; - constexpr explicit measurement(const value_type& val, const value_type& err = {}) : - value_(val) + constexpr explicit measurement(const value_type& val, const value_type& err = {}) : value_(val) { // it sucks that using declaration cannot be provided for a constructor initializer list using namespace std; @@ -133,7 +132,8 @@ void example() const Speed auto v1 = a * t; #if UNITS_DOWNCAST_MODE == 0 - std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; + std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) + << '\n'; #else std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; #endif diff --git a/example/references/avg_speed.cpp b/example/references/avg_speed.cpp index aba1123e..3c9cecca 100644 --- a/example/references/avg_speed.cpp +++ b/example/references/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -169,7 +165,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -178,20 +176,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/references/box_example.cpp b/example/references/box_example.cpp index 48a8656e..b94c34d2 100644 --- a/example/references/box_example.cpp +++ b/example/references/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -50,7 +50,10 @@ class Box { si::length height_; si::density density_ = air_density; public: - constexpr Box(const si::length& length, const si::length& width, si::length height) : base_(length * width), height_(std::move(height)) {} + constexpr Box(const si::length& length, const si::length& width, si::length height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr si::force filled_weight() const { @@ -90,13 +93,13 @@ int main() auto box = Box(1000.0 * mm, 500.0 * mm, height); box.set_contents_density(1000.0 * (kg / m3)); - const auto fill_time = 200.0 * s; // time since starting fill - const auto measured_mass = 20.0 * kg; // measured mass at fill_time + const auto fill_time = 200.0 * s; // time since starting fill + const auto measured_mass = 20.0 * kg; // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/references/capacitor_time_curve.cpp b/example/references/capacitor_time_curve.cpp index 844bf4d2..45e1c45b 100644 --- a/example/references/capacitor_time_curve.cpp +++ b/example/references/capacitor_time_curve.cpp @@ -26,7 +26,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/references/clcpp_response.cpp b/example/references/clcpp_response.cpp index 758dafa9..c19eb459 100644 --- a/example/references/clcpp_response.cpp +++ b/example/references/clcpp_response.cpp @@ -39,15 +39,15 @@ void simple_quantities() using distance = si::length; using duration = si::time; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_SHADOW + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr distance km = 1.0 * references::km; constexpr distance miles = 1.0 * mi; constexpr duration sec = 1 * s; constexpr duration min = 1 * references::min; constexpr duration hr = 1 * h; -UNITS_DIAGNOSTIC_POP + UNITS_DIAGNOSTIC_POP std::cout << "A physical quantities library can choose the simple\n"; std::cout << "option to provide output using a single type for each base unit:\n\n"; @@ -66,8 +66,8 @@ void quantities_with_typed_units() using namespace units::isq::si::international; using namespace units::isq::si::international::references; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_SHADOW + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr length km = 1.0 * si::references::km; constexpr length miles = 1.0 * mi; @@ -76,7 +76,7 @@ UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr si::time sec = 1 * s; constexpr si::time min = 1 * si::references::min; constexpr si::time hr = 1 * h; -UNITS_DIAGNOSTIC_POP + UNITS_DIAGNOSTIC_POP std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; std::cout << km << '\n'; diff --git a/example/references/experimental_angle.cpp b/example/references/experimental_angle.cpp index 76a1e6a8..61421f2c 100644 --- a/example/references/experimental_angle.cpp +++ b/example/references/experimental_angle.cpp @@ -20,17 +20,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include // IWYU pragma: keep UNITS_DIAGNOSTIC_PUSH UNITS_DIAGNOSTIC_IGNORE_SHADOW -#include // 'N' (Newton) shadows a template parameter traditionally used as a size of the array +#include // 'N' (Newton) shadows a template parameter traditionally used as a size of the array UNITS_DIAGNOSTIC_POP #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/references/foot_pound_second.cpp b/example/references/foot_pound_second.cpp index b76a2b53..f947ed4c 100644 --- a/example/references/foot_pound_second.cpp +++ b/example/references/foot_pound_second.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -56,7 +56,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -68,16 +68,27 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::references; const auto waterDensity = 62.4 * (lb / ft3); std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing", fmt_line, si::mass>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at", fmt_line, si::speed>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() @@ -87,13 +98,37 @@ int main() using units::isq::si::fps::references::ft; // collides with si::femtotonne (alias unit of mass) // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{251. * m}, .draft{9.3 * m}, .beam{36 * m}, .speed{56 * (km / h)}, .mass{50'300 * t}, .mainGuns{380 * mm}, .shellMass{800 * kg}, .shellSpeed{820. * (m / s)}, .power{110.45 * kW}}; + auto bismark = Ship{.length{251. * m}, + .draft{9.3 * m}, + .beam{36 * m}, + .speed{56 * (km / h)}, + .mass{50'300 * t}, + .mainGuns{380 * mm}, + .shellMass{800 * kg}, + .shellSpeed{820. * (m / s)}, + .power{110.45 * kW}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{860. * ft}, .draft{37. * ft + 2. * in}, .beam{108. * ft + 2. * in}, .speed{33 * knot}, .mass{57'540 * lton}, .mainGuns{16 * in}, .shellMass{2700 * lb}, .shellSpeed{2690. * (ft / s)}, .power{212'000 * hp}}; + auto iowa = Ship{.length{860. * ft}, + .draft{37. * ft + 2. * in}, + .beam{108. * ft + 2. * in}, + .speed{33 * knot}, + .mass{57'540 * lton}, + .mainGuns{16 * in}, + .shellMass{2700 * lb}, + .shellSpeed{2690. * (ft / s)}, + .power{212'000 * hp}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{745.1 * ft}, .draft{33. * ft + 7.5 * in}, .beam{103.2 * ft + 2.5 * in}, .speed{28.3 * knot}, .mass{42'245 * lton}, .mainGuns{14 * in}, .shellMass{1'590 * lb}, .shellSpeed{2483. * (ft / s)}, .power{110'000 * hp}}; + auto kgv = Ship{.length{745.1 * ft}, + .draft{33. * ft + 7.5 * in}, + .beam{103.2 * ft + 2.5 * in}, + .speed{28.3 * knot}, + .mass{42'245 * lton}, + .mainGuns{14 * in}, + .shellMass{1'590 * lb}, + .shellSpeed{2483. * (ft / s)}, + .power{110'000 * hp}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/references/glide_computer_example.cpp b/example/references/glide_computer_example.cpp index 701f04d2..ccfa543c 100644 --- a/example/references/glide_computer_example.cpp +++ b/example/references/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace si::references; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(83 * (km / h)), rate_of_climb(-0.7389 * (m / s))}}, - glider{"SZD-51 Junior", {velocity(80 * (km / h)), rate_of_climb(-0.6349 * (m / s))}}, - glider{"SZD-48 Jantar Std 3", {velocity(110 * (km / h)), rate_of_climb(-0.77355 * (m / s))}}, - glider{"SZD-56 Diana", {velocity(110 * (km / h)), rate_of_climb(-0.63657 * (m / s))}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(83 * (km / h)), rate_of_climb(-0.7389 * (m / s))}}, + glider{"SZD-51 Junior", {velocity(80 * (km / h)), rate_of_climb(-0.6349 * (m / s))}}, + glider{"SZD-48 Jantar Std 3", {velocity(110 * (km / h)), rate_of_climb(-0.77355 * (m / s))}}, + glider{"SZD-56 Diana", {velocity(110 * (km / h)), rate_of_climb(-0.63657 * (m / s))}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace si::references; static const std::array weather_conditions = { - std::pair("Good", weather{height(1900 * m), rate_of_climb(4.3 * (m / s))}), - std::pair("Medium", weather{height(1550 * m), rate_of_climb(2.8 * (m / s))}), - std::pair("Bad", weather{height(850 * m), rate_of_climb(1.8 * (m / s))})}; + std::pair("Good", weather{height(1900 * m), rate_of_climb(4.3 * (m / s))}), + std::pair("Medium", weather{height(1550 * m), rate_of_climb(2.8 * (m / s))}), + std::pair("Bad", weather{height(850 * m), rate_of_climb(1.8 * (m / s))})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::isq::si::international::references; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16 * ft)}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115 * ft)} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16 * ft)}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115 * ft)} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/references/linear_algebra.cpp b/example/references/linear_algebra.cpp index f3b23a49..39d1fefe 100644 --- a/example/references/linear_algebra.cpp +++ b/example/references/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -73,9 +73,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { 1 * m, 2 * m, 3 * m }; - vector> u = { 3 * m, 2 * m, 1 * m }; - vector> t = { 3 * km, 2 * km, 1 * km }; + vector> v = {1 * m, 2 * m, 3 * m}; + vector> u = {3 * m, 2 * m, 1 * m}; + vector> t = {3 * km, 2 * km, 1 * km}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -90,8 +90,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { 1 * m, 2 * m, 3 * m }; - vector> u = { 3 * m, 2 * m, 1 * m }; + vector> v = {1 * m, 2 * m, 3 * m}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -104,8 +104,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { 1 * N, 2 * N, 3 * N }; - vector> u = { 3 * m, 2 * m, 1 * m }; + vector> v = {1 * N, 2 * N, 3 * N}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -119,7 +119,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { 4 * m, 8 * m, 12 * m }; + vector> v = {4 * m, 8 * m, 12 * m}; std::cout << "v = " << v << "\n"; @@ -140,9 +140,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; - matrix> u = {{ 3 * m, 2 * m, 1 * m }, { 3 * m, 2 * m, 1 * m }, { 3 * m, 2 * m, 1 * m }}; - matrix> t = {{ 3 * mm, 2 * mm, 1 * mm }, { 3 * mm, 2 * mm, 1 * mm }, { 3 * mm, 2 * mm, 1 * mm }}; + matrix> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; + matrix> u = {{3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}}; + matrix> t = {{3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -159,8 +159,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; - vector> u = { 3 * m, 2 * m, 1 * m }; + matrix> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -173,8 +173,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { 1 * N, 2 * N, 3 * N }; - matrix> u = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; + vector> v = {1 * N, 2 * N, 3 * N}; + matrix> u = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -188,7 +188,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ 2 * m, 4 * m, 6 * m }, { 4 * m, 6 * m, 8 * m }, { 8 * m, 4 * m, 2 * m }}; + matrix> v = {{2 * m, 4 * m, 6 * m}, {4 * m, 6 * m, 8 * m}, {8 * m, 4 * m, 2 * m}}; std::cout << "v =\n" << v << "\n"; @@ -215,9 +215,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -232,8 +232,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -246,8 +246,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -261,7 +261,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -285,9 +285,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -304,8 +304,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -318,8 +318,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -333,7 +333,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/references/total_energy.cpp b/example/references/total_energy.cpp index e6c911bf..ec6e8f3e 100644 --- a/example/references/total_energy.cpp +++ b/example/references/total_energy.cpp @@ -25,7 +25,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -87,18 +87,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/references/unknown_dimension.cpp b/example/references/unknown_dimension.cpp index 8e5fe29a..d2ea9c47 100644 --- a/example/references/unknown_dimension.cpp +++ b/example/references/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = 10 * s; Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * (50 * m); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / (100 * m); // back to known dimensions again + auto temp1 = + v1 * (50 * m); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / (100 * m); // back to known dimensions again Length auto d2 = v2 * (60 * s); std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/src/core/include/units/generic/angle.h b/src/core/include/units/generic/angle.h index 00c723dc..9aefafbb 100644 --- a/src/core/include/units/generic/angle.h +++ b/src/core/include/units/generic/angle.h @@ -48,12 +48,16 @@ using angle = quantity, U, Rep>; inline namespace literals { // rad -constexpr auto operator"" _q_rad(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return angle(static_cast(l)); } +constexpr auto operator"" _q_rad(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return angle(static_cast(l)); +} constexpr auto operator"" _q_rad(long double l) { return angle(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -69,6 +73,6 @@ using namespace angle_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units diff --git a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h index 507495e7..97990439 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h +++ b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h @@ -44,12 +44,16 @@ using acceleration = quantity; inline namespace literals { // ft/s2 -constexpr auto operator"" _q_ft_per_s2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return acceleration(static_cast(l)); } +constexpr auto operator"" _q_ft_per_s2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return acceleration(static_cast(l)); +} constexpr auto operator"" _q_ft_per_s2(long double l) { return acceleration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -57,8 +61,9 @@ constexpr auto operator"" _q_ft_per_s2(long double l) { return acceleration using ft_per_s2 = units::isq::si::fps::acceleration; +template +using ft_per_s2 = units::isq::si::fps::acceleration; } // namespace units::aliases::isq::si::fps::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/area.h b/src/systems/si-fps/include/units/isq/si/fps/area.h index d02e5732..acafd67f 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/area.h +++ b/src/systems/si-fps/include/units/isq/si/fps/area.h @@ -46,12 +46,16 @@ using area = quantity; inline namespace literals { // ft2 -constexpr auto operator"" _q_ft2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ft2(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -75,8 +79,9 @@ using namespace area_references; namespace units::aliases::isq::si::fps::inline area { -template using ft2 = units::isq::si::fps::area; +template +using ft2 = units::isq::si::fps::area; -} // namespace units::aliases::isq::si::fps::inlipne area +} // namespace units::aliases::isq::si::fps::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/density.h b/src/systems/si-fps/include/units/isq/si/fps/density.h index 1d807c25..f2aa0e65 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/density.h +++ b/src/systems/si-fps/include/units/isq/si/fps/density.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si::fps { @@ -46,12 +46,16 @@ using density = quantity; inline namespace literals { // lb/ft³ -constexpr auto operator"" _q_lb_per_ft3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return density(static_cast(l)); } +constexpr auto operator"" _q_lb_per_ft3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return density(static_cast(l)); +} constexpr auto operator"" _q_lb_per_ft3(long double l) { return density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -59,8 +63,9 @@ constexpr auto operator"" _q_lb_per_ft3(long double l) { return density using lb_per_ft3 = units::isq::si::fps::density; +template +using lb_per_ft3 = units::isq::si::fps::density; } // namespace units::aliases::isq::si::fps::inline density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/energy.h b/src/systems/si-fps/include/units/isq/si/fps/energy.h index 7d430d4f..7278f016 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/energy.h +++ b/src/systems/si-fps/include/units/isq/si/fps/energy.h @@ -40,7 +40,7 @@ struct foot_poundal : unit {}; struct dim_energy : isq::dim_energy {}; // https://en.wikipedia.org/wiki/Foot-pound_(energy) - struct foot_pound_force : derived_unit {}; +struct foot_pound_force : derived_unit {}; template U, Representation Rep = double> using energy = quantity; @@ -50,16 +50,24 @@ using energy = quantity; inline namespace literals { // foot poundal -constexpr auto operator"" _q_ft_pdl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ft_pdl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ft_pdl(long double l) { return energy(l); } // foot_pound force -constexpr auto operator"" _q_ft_lbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ft_lbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ft_lbf(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -67,9 +75,11 @@ constexpr auto operator"" _q_ft_lbf(long double l) { return energy using ft_pdl = units::isq::si::fps::energy; -template using ft_lbf = units::isq::si::fps::energy; +template +using ft_pdl = units::isq::si::fps::energy; +template +using ft_lbf = units::isq::si::fps::energy; } // namespace units::aliases::isq::si::fps::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/force.h b/src/systems/si-fps/include/units/isq/si/fps/force.h index ebccdb3a..8958ca44 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/force.h +++ b/src/systems/si-fps/include/units/isq/si/fps/force.h @@ -57,20 +57,32 @@ using force = quantity; inline namespace literals { // poundal -constexpr auto operator"" _q_pdl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_pdl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_pdl(long double l) { return force(l); } // pound force -constexpr auto operator"" _q_lbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_lbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_lbf(long double l) { return force(l); } // kilopound force -constexpr auto operator"" _q_klbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_klbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_klbf(long double l) { return force(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -88,7 +100,7 @@ using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -96,10 +108,13 @@ using namespace force_references; namespace units::aliases::isq::si::fps::inline force { -template using pdl = units::isq::si::fps::force; -template using lbf = units::isq::si::fps::force; -template using klbf = units::isq::si::fps::force; +template +using pdl = units::isq::si::fps::force; +template +using lbf = units::isq::si::fps::force; +template +using klbf = units::isq::si::fps::force; } // namespace units::aliases::isq::si::fps::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/fps.h b/src/systems/si-fps/include/units/isq/si/fps/fps.h index 1bf09cd9..6bd88132 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/fps.h +++ b/src/systems/si-fps/include/units/isq/si/fps/fps.h @@ -23,17 +23,16 @@ #pragma once // IWYU pragma: begin_exports -#include -#include -#include - #include #include #include #include #include +#include +#include #include #include #include +#include #include // IWYU pragma: end_exports diff --git a/src/systems/si-fps/include/units/isq/si/fps/pressure.h b/src/systems/si-fps/include/units/isq/si/fps/pressure.h index 9a0706b0..2c87269f 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/pressure.h +++ b/src/systems/si-fps/include/units/isq/si/fps/pressure.h @@ -43,9 +43,12 @@ struct dim_pressure : isq::dim_pressure U, Representation Rep = double> using pressure = quantity; -struct pound_force_per_foot_sq : named_scaled_unit {}; +struct pound_force_per_foot_sq : + named_scaled_unit {}; -struct pound_force_per_inch_sq : named_scaled_unit {}; +struct pound_force_per_inch_sq : + named_scaled_unit {}; struct kilopound_force_per_inch_sq : prefixed_unit {}; @@ -54,20 +57,32 @@ struct kilopound_force_per_inch_sq : prefixed_unit(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_pdl_per_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_pdl_per_ft2(long double l) { return pressure(l); } // Pounds per square inch -constexpr auto operator"" _q_psi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_psi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_psi(long double l) { return pressure(l); } // kilopounds per square inch -constexpr auto operator"" _q_kpsi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_kpsi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_kpsi(long double l) { return pressure(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -84,7 +99,7 @@ using namespace pressure_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -92,10 +107,13 @@ using namespace pressure_references; namespace units::aliases::isq::si::fps::inline pressure { -template using pdl_per_ft2 = units::isq::si::fps::pressure; -template using psi = units::isq::si::fps::pressure; -template using kpsi = units::isq::si::fps::pressure; +template +using pdl_per_ft2 = units::isq::si::fps::pressure; +template +using psi = units::isq::si::fps::pressure; +template +using kpsi = units::isq::si::fps::pressure; } // namespace units::aliases::isq::si::fps::inline pressure -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/speed.h b/src/systems/si-fps/include/units/isq/si/fps/speed.h index 098498d5..04302b86 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/speed.h +++ b/src/systems/si-fps/include/units/isq/si/fps/speed.h @@ -41,8 +41,8 @@ struct dim_speed : isq::dim_speed U, Representation Rep = double> using speed = quantity; -struct mile_per_hour : derived_unit{}; -struct nautical_mile_per_hour : derived_unit{}; +struct mile_per_hour : derived_unit {}; +struct nautical_mile_per_hour : derived_unit {}; struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS @@ -50,20 +50,32 @@ struct knot : alias_unit {}; inline namespace literals { // ft/s -constexpr auto operator"" _q_ft_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_ft_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_ft_per_s(long double l) { return speed(l); } // mph -constexpr auto operator"" _q_mph(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_mph(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_mph(long double l) { return speed(l); } // kn -constexpr auto operator"" _q_knot(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_knot(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_knot(long double l) { return speed(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -80,7 +92,7 @@ using namespace speed_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -88,10 +100,13 @@ using namespace speed_references; namespace units::aliases::isq::si::fps::inline speed { -template using ft_per_s = units::isq::si::fps::speed; -template using mph = units::isq::si::fps::speed; -template using knot = units::isq::si::fps::speed; +template +using ft_per_s = units::isq::si::fps::speed; +template +using mph = units::isq::si::fps::speed; +template +using knot = units::isq::si::fps::speed; } // namespace units::aliases::isq::si::fps::inline speed -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-hep/include/units/isq/si/hep/area.h b/src/systems/si-hep/include/units/isq/si/hep/area.h index 53aa3603..9718fb2d 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/area.h +++ b/src/systems/si-hep/include/units/isq/si/hep/area.h @@ -50,27 +50,63 @@ struct milli_barn : prefixed_unit {}; #ifndef UNITS_NO_LITERALS inline namespace literals { -constexpr auto operator"" _q_yb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_yb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_yb(long double l) { return area(l); } -constexpr auto operator"" _q_zb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_zb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_zb(long double l) { return area(l); } -constexpr auto operator"" _q_ab(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ab(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ab(long double l) { return area(l); } -constexpr auto operator"" _q_fb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_fb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_fb(long double l) { return area(l); } -constexpr auto operator"" _q_pb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_pb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_pb(long double l) { return area(l); } -constexpr auto operator"" _q_nb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_nb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_nb(long double l) { return area(l); } -constexpr auto operator"" _q_ub(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ub(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ub(long double l) { return area(l); } -constexpr auto operator"" _q_mb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_mb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_mb(long double l) { return area(l); } -constexpr auto operator"" _q_b(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_b(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_b(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -86,7 +122,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::hep @@ -94,8 +130,9 @@ using namespace area_references; namespace units::aliases::isq::si::hep::inline area { -template using barn = units::isq::si::area; +template +using barn = units::isq::si::area; } // namespace units::aliases::isq::si::hep::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/area.h b/src/systems/si-international/include/units/isq/si/international/area.h index 5a5489d9..74bd6ad1 100644 --- a/src/systems/si-international/include/units/isq/si/international/area.h +++ b/src/systems/si-international/include/units/isq/si/international/area.h @@ -42,12 +42,16 @@ struct square_foot : derived_unit(l)); return si::area(static_cast(l)); } +constexpr auto operator"" _q_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::area(static_cast(l)); +} constexpr auto operator"" _q_ft2(long double l) { return si::area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -63,7 +67,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::international @@ -71,8 +75,9 @@ using namespace area_references; namespace units::aliases::isq::si::international::inline area { -template using ft2 = units::isq::si::area; +template +using ft2 = units::isq::si::area; } // namespace units::aliases::isq::si::international::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/international.h b/src/systems/si-international/include/units/isq/si/international/international.h index 9bdc7ec4..f3a8f2ab 100644 --- a/src/systems/si-international/include/units/isq/si/international/international.h +++ b/src/systems/si-international/include/units/isq/si/international/international.h @@ -23,9 +23,8 @@ #pragma once // IWYU pragma: begin_exports -#include - #include +#include #include #include // IWYU pragma: end_exports diff --git a/src/systems/si/include/units/isq/si/absorbed_dose.h b/src/systems/si/include/units/isq/si/absorbed_dose.h index 4be7370e..965665e8 100644 --- a/src/systems/si/include/units/isq/si/absorbed_dose.h +++ b/src/systems/si/include/units/isq/si/absorbed_dose.h @@ -67,92 +67,176 @@ using absorbed_dose = quantity; inline namespace literals { // Gy -constexpr auto operator"" _q_Gy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_Gy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_Gy(long double l) { return absorbed_dose(l); } // yGy -constexpr auto operator"" _q_yGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_yGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_yGy(long double l) { return absorbed_dose(l); } // zGy -constexpr auto operator"" _q_zGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_zGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_zGy(long double l) { return absorbed_dose(l); } // aGy -constexpr auto operator"" _q_aGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_aGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_aGy(long double l) { return absorbed_dose(l); } // fGy -constexpr auto operator"" _q_fGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_fGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_fGy(long double l) { return absorbed_dose(l); } // pGy -constexpr auto operator"" _q_pGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_pGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_pGy(long double l) { return absorbed_dose(l); } // nGy -constexpr auto operator"" _q_nGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_nGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_nGy(long double l) { return absorbed_dose(l); } // uGy -constexpr auto operator"" _q_uGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_uGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_uGy(long double l) { return absorbed_dose(l); } // mGy -constexpr auto operator"" _q_mGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_mGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_mGy(long double l) { return absorbed_dose(l); } // cGy -constexpr auto operator"" _q_cGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_cGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_cGy(long double l) { return absorbed_dose(l); } // dGy -constexpr auto operator"" _q_dGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_dGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_dGy(long double l) { return absorbed_dose(l); } // daGy -constexpr auto operator"" _q_daGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_daGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_daGy(long double l) { return absorbed_dose(l); } // hGy -constexpr auto operator"" _q_hGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_hGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_hGy(long double l) { return absorbed_dose(l); } // kGy -constexpr auto operator"" _q_kGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_kGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_kGy(long double l) { return absorbed_dose(l); } // MGy -constexpr auto operator"" _q_MGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_MGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_MGy(long double l) { return absorbed_dose(l); } // GGy -constexpr auto operator"" _q_GGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_GGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_GGy(long double l) { return absorbed_dose(l); } // TGy -constexpr auto operator"" _q_TGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_TGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_TGy(long double l) { return absorbed_dose(l); } // PGy -constexpr auto operator"" _q_PGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_PGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_PGy(long double l) { return absorbed_dose(l); } // EGy -constexpr auto operator"" _q_EGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_EGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_EGy(long double l) { return absorbed_dose(l); } // ZGy -constexpr auto operator"" _q_ZGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_ZGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_ZGy(long double l) { return absorbed_dose(l); } // YGy -constexpr auto operator"" _q_YGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_YGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_YGy(long double l) { return absorbed_dose(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -188,7 +272,7 @@ using namespace absorbed_dose_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -196,28 +280,49 @@ using namespace absorbed_dose_references; namespace units::aliases::isq::si::inline absorbed_dose { -template using Gy = units::isq::si::absorbed_dose; -template using yGy = units::isq::si::absorbed_dose; -template using zGy = units::isq::si::absorbed_dose; -template using aGy = units::isq::si::absorbed_dose; -template using fGy = units::isq::si::absorbed_dose; -template using pGy = units::isq::si::absorbed_dose; -template using nGy = units::isq::si::absorbed_dose; -template using uGy = units::isq::si::absorbed_dose; -template using mGy = units::isq::si::absorbed_dose; -template using cGy = units::isq::si::absorbed_dose; -template using dGy = units::isq::si::absorbed_dose; -template using daGy = units::isq::si::absorbed_dose; -template using hGy = units::isq::si::absorbed_dose; -template using kGy = units::isq::si::absorbed_dose; -template using MGy = units::isq::si::absorbed_dose; -template using GGy = units::isq::si::absorbed_dose; -template using TGy = units::isq::si::absorbed_dose; -template using PGy = units::isq::si::absorbed_dose; -template using EGy = units::isq::si::absorbed_dose; -template using ZGy = units::isq::si::absorbed_dose; -template using YGy = units::isq::si::absorbed_dose; +template +using Gy = units::isq::si::absorbed_dose; +template +using yGy = units::isq::si::absorbed_dose; +template +using zGy = units::isq::si::absorbed_dose; +template +using aGy = units::isq::si::absorbed_dose; +template +using fGy = units::isq::si::absorbed_dose; +template +using pGy = units::isq::si::absorbed_dose; +template +using nGy = units::isq::si::absorbed_dose; +template +using uGy = units::isq::si::absorbed_dose; +template +using mGy = units::isq::si::absorbed_dose; +template +using cGy = units::isq::si::absorbed_dose; +template +using dGy = units::isq::si::absorbed_dose; +template +using daGy = units::isq::si::absorbed_dose; +template +using hGy = units::isq::si::absorbed_dose; +template +using kGy = units::isq::si::absorbed_dose; +template +using MGy = units::isq::si::absorbed_dose; +template +using GGy = units::isq::si::absorbed_dose; +template +using TGy = units::isq::si::absorbed_dose; +template +using PGy = units::isq::si::absorbed_dose; +template +using EGy = units::isq::si::absorbed_dose; +template +using ZGy = units::isq::si::absorbed_dose; +template +using YGy = units::isq::si::absorbed_dose; } // namespace units::aliases::isq::si::inline absorbed_dose -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/acceleration.h b/src/systems/si/include/units/isq/si/acceleration.h index c6e8110e..313c1df5 100644 --- a/src/systems/si/include/units/isq/si/acceleration.h +++ b/src/systems/si/include/units/isq/si/acceleration.h @@ -44,12 +44,16 @@ using acceleration = quantity; inline namespace literals { // m/s2 -constexpr auto operator"" _q_m_per_s2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return acceleration(static_cast(l)); } +constexpr auto operator"" _q_m_per_s2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return acceleration(static_cast(l)); +} constexpr auto operator"" _q_m_per_s2(long double l) { return acceleration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -57,8 +61,9 @@ constexpr auto operator"" _q_m_per_s2(long double l) { return acceleration using m_per_s2 = units::isq::si::acceleration; +template +using m_per_s2 = units::isq::si::acceleration; } // namespace units::aliases::isq::si::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/amount_of_substance.h b/src/systems/si/include/units/isq/si/amount_of_substance.h index 79282af9..e5d40c80 100644 --- a/src/systems/si/include/units/isq/si/amount_of_substance.h +++ b/src/systems/si/include/units/isq/si/amount_of_substance.h @@ -46,12 +46,16 @@ using amount_of_substance = quantity; inline namespace literals { // mol -constexpr auto operator"" _q_mol(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return amount_of_substance(static_cast(l)); } +constexpr auto operator"" _q_mol(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return amount_of_substance(static_cast(l)); +} constexpr auto operator"" _q_mol(long double l) { return amount_of_substance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace amount_of_substance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -75,8 +79,9 @@ using namespace amount_of_substance_references; namespace units::aliases::isq::si::inline amount_of_substance { -template using mol = units::isq::si::amount_of_substance; +template +using mol = units::isq::si::amount_of_substance; } // namespace units::aliases::isq::si::inline amount_of_substance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/angular_velocity.h b/src/systems/si/include/units/isq/si/angular_velocity.h index 52fd092b..fbb6e5c6 100644 --- a/src/systems/si/include/units/isq/si/angular_velocity.h +++ b/src/systems/si/include/units/isq/si/angular_velocity.h @@ -36,7 +36,8 @@ namespace units::isq::si { struct radian_per_second : named_unit {}; -struct dim_angular_velocity : isq::dim_angular_velocity, dim_time> {}; +struct dim_angular_velocity : + isq::dim_angular_velocity, dim_time> {}; template U, Representation Rep = double> using angular_velocity = quantity; @@ -46,12 +47,16 @@ using angular_velocity = quantity; inline namespace literals { // rad / s -constexpr auto operator"" _q_rad_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return angular_velocity(static_cast(l)); } +constexpr auto operator"" _q_rad_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return angular_velocity(static_cast(l)); +} constexpr auto operator"" _q_rad_per_s(long double l) { return angular_velocity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -59,8 +64,9 @@ constexpr auto operator"" _q_rad_per_s(long double l) { return angular_velocity< namespace units::aliases::isq::si::inline angular_velocity { -template using rad_per_s = units::isq::si::angular_velocity; +template +using rad_per_s = units::isq::si::angular_velocity; } // namespace units::aliases::isq::si::inline angular_velocity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/area.h b/src/systems/si/include/units/isq/si/area.h index 13d21a1a..98bcb87c 100644 --- a/src/systems/si/include/units/isq/si/area.h +++ b/src/systems/si/include/units/isq/si/area.h @@ -68,96 +68,184 @@ using area = quantity; inline namespace literals { // m2 -constexpr auto operator"" _q_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_m2(long double l) { return area(l); } // ym2 -constexpr auto operator"" _q_ym2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ym2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ym2(long double l) { return area(l); } // zm2 -constexpr auto operator"" _q_zm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_zm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_zm2(long double l) { return area(l); } // am2 -constexpr auto operator"" _q_am2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_am2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_am2(long double l) { return area(l); } // fm2 -constexpr auto operator"" _q_fm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_fm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_fm2(long double l) { return area(l); } // pm2 -constexpr auto operator"" _q_pm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_pm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_pm2(long double l) { return area(l); } // nm2 -constexpr auto operator"" _q_nm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_nm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_nm2(long double l) { return area(l); } // um2 -constexpr auto operator"" _q_um2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_um2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_um2(long double l) { return area(l); } // mm2 -constexpr auto operator"" _q_mm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_mm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_mm2(long double l) { return area(l); } // cm2 -constexpr auto operator"" _q_cm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_cm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_cm2(long double l) { return area(l); } // dm2 -constexpr auto operator"" _q_dm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_dm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_dm2(long double l) { return area(l); } // dam2 -constexpr auto operator"" _q_dam2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_dam2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_dam2(long double l) { return area(l); } // hm2 -constexpr auto operator"" _q_hm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_hm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_hm2(long double l) { return area(l); } // km2 -constexpr auto operator"" _q_km2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_km2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_km2(long double l) { return area(l); } // Mm2 -constexpr auto operator"" _q_Mm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Mm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Mm2(long double l) { return area(l); } // Gm2 -constexpr auto operator"" _q_Gm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Gm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Gm2(long double l) { return area(l); } // Tm2 -constexpr auto operator"" _q_Tm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Tm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Tm2(long double l) { return area(l); } // Pm2 -constexpr auto operator"" _q_Pm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Pm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Pm2(long double l) { return area(l); } // Em2 -constexpr auto operator"" _q_Em2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Em2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Em2(long double l) { return area(l); } // Zm2 -constexpr auto operator"" _q_Zm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Zm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Zm2(long double l) { return area(l); } // Ym2 -constexpr auto operator"" _q_Ym2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Ym2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Ym2(long double l) { return area(l); } // ha -constexpr auto operator"" _q_ha(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ha(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ha(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -195,7 +283,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -203,30 +291,52 @@ using namespace area_references; namespace units::aliases::isq::si::inline area { -template using m2 = units::isq::si::area; -template using ym2 = units::isq::si::area; -template using zm2 = units::isq::si::area; -template using am2 = units::isq::si::area; -template using fm2 = units::isq::si::area; -template using pm2 = units::isq::si::area; -template using nm2 = units::isq::si::area; -template using um2 = units::isq::si::area; -template using mm2 = units::isq::si::area; -template using cm2 = units::isq::si::area; -template using dm2 = units::isq::si::area; -template using dam2 = units::isq::si::area; -template using hm2 = units::isq::si::area; -template using km2 = units::isq::si::area; -template using Mm2 = units::isq::si::area; -template using Gm2 = units::isq::si::area; -template using Tm2 = units::isq::si::area; -template using Pm2 = units::isq::si::area; -template using Em2 = units::isq::si::area; -template using Zm2 = units::isq::si::area; -template using Ym2 = units::isq::si::area; +template +using m2 = units::isq::si::area; +template +using ym2 = units::isq::si::area; +template +using zm2 = units::isq::si::area; +template +using am2 = units::isq::si::area; +template +using fm2 = units::isq::si::area; +template +using pm2 = units::isq::si::area; +template +using nm2 = units::isq::si::area; +template +using um2 = units::isq::si::area; +template +using mm2 = units::isq::si::area; +template +using cm2 = units::isq::si::area; +template +using dm2 = units::isq::si::area; +template +using dam2 = units::isq::si::area; +template +using hm2 = units::isq::si::area; +template +using km2 = units::isq::si::area; +template +using Mm2 = units::isq::si::area; +template +using Gm2 = units::isq::si::area; +template +using Tm2 = units::isq::si::area; +template +using Pm2 = units::isq::si::area; +template +using Em2 = units::isq::si::area; +template +using Zm2 = units::isq::si::area; +template +using Ym2 = units::isq::si::area; -template using ha = units::isq::si::area; +template +using ha = units::isq::si::area; } // namespace units::aliases::isq::si::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/capacitance.h b/src/systems/si/include/units/isq/si/capacitance.h index df1ddd8a..ddea6793 100644 --- a/src/systems/si/include/units/isq/si/capacitance.h +++ b/src/systems/si/include/units/isq/si/capacitance.h @@ -30,8 +30,8 @@ // IWYU pragma: end_exports #include -#include #include +#include #include namespace units::isq::si { @@ -68,92 +68,176 @@ using capacitance = quantity; inline namespace literals { // F -constexpr auto operator"" _q_F(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_F(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_F(long double l) { return capacitance(l); } // yF -constexpr auto operator"" _q_yF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_yF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_yF(long double l) { return capacitance(l); } // zF -constexpr auto operator"" _q_zF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_zF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_zF(long double l) { return capacitance(l); } // aF -constexpr auto operator"" _q_aF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_aF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_aF(long double l) { return capacitance(l); } // fF -constexpr auto operator"" _q_fF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_fF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_fF(long double l) { return capacitance(l); } // pF -constexpr auto operator"" _q_pF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_pF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_pF(long double l) { return capacitance(l); } // nF -constexpr auto operator"" _q_nF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_nF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_nF(long double l) { return capacitance(l); } // uF -constexpr auto operator"" _q_uF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_uF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_uF(long double l) { return capacitance(l); } // mF -constexpr auto operator"" _q_mF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_mF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_mF(long double l) { return capacitance(l); } // cF -constexpr auto operator"" _q_cF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_cF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_cF(long double l) { return capacitance(l); } // dF -constexpr auto operator"" _q_dF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_dF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_dF(long double l) { return capacitance(l); } // daF -constexpr auto operator"" _q_daF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_daF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_daF(long double l) { return capacitance(l); } // hF -constexpr auto operator"" _q_hF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_hF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_hF(long double l) { return capacitance(l); } // kF -constexpr auto operator"" _q_kF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_kF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_kF(long double l) { return capacitance(l); } // MF -constexpr auto operator"" _q_MF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_MF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_MF(long double l) { return capacitance(l); } // GF -constexpr auto operator"" _q_GF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_GF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_GF(long double l) { return capacitance(l); } // TF -constexpr auto operator"" _q_TF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_TF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_TF(long double l) { return capacitance(l); } // PF -constexpr auto operator"" _q_PF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_PF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_PF(long double l) { return capacitance(l); } // EF -constexpr auto operator"" _q_EF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_EF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_EF(long double l) { return capacitance(l); } // ZF -constexpr auto operator"" _q_ZF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_ZF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_ZF(long double l) { return capacitance(l); } // YF -constexpr auto operator"" _q_YF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_YF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_YF(long double l) { return capacitance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace capacitance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace capacitance_references; namespace units::aliases::isq::si::inline capacitance { -template using F = units::isq::si::capacitance; -template using yF = units::isq::si::capacitance; -template using zF = units::isq::si::capacitance; -template using aF = units::isq::si::capacitance; -template using fF = units::isq::si::capacitance; -template using pF = units::isq::si::capacitance; -template using nF = units::isq::si::capacitance; -template using uF = units::isq::si::capacitance; -template using mF = units::isq::si::capacitance; -template using cF = units::isq::si::capacitance; -template using dF = units::isq::si::capacitance; -template using daF = units::isq::si::capacitance; -template using hF = units::isq::si::capacitance; -template using kF = units::isq::si::capacitance; -template using MF = units::isq::si::capacitance; -template using GF = units::isq::si::capacitance; -template using TF = units::isq::si::capacitance; -template using PF = units::isq::si::capacitance; -template using EF = units::isq::si::capacitance; -template using ZF = units::isq::si::capacitance; -template using YF = units::isq::si::capacitance; +template +using F = units::isq::si::capacitance; +template +using yF = units::isq::si::capacitance; +template +using zF = units::isq::si::capacitance; +template +using aF = units::isq::si::capacitance; +template +using fF = units::isq::si::capacitance; +template +using pF = units::isq::si::capacitance; +template +using nF = units::isq::si::capacitance; +template +using uF = units::isq::si::capacitance; +template +using mF = units::isq::si::capacitance; +template +using cF = units::isq::si::capacitance; +template +using dF = units::isq::si::capacitance; +template +using daF = units::isq::si::capacitance; +template +using hF = units::isq::si::capacitance; +template +using kF = units::isq::si::capacitance; +template +using MF = units::isq::si::capacitance; +template +using GF = units::isq::si::capacitance; +template +using TF = units::isq::si::capacitance; +template +using PF = units::isq::si::capacitance; +template +using EF = units::isq::si::capacitance; +template +using ZF = units::isq::si::capacitance; +template +using YF = units::isq::si::capacitance; } // namespace units::aliases::isq::si::inline capacitance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/concentration.h b/src/systems/si/include/units/isq/si/concentration.h index 903f943a..d59b3143 100644 --- a/src/systems/si/include/units/isq/si/concentration.h +++ b/src/systems/si/include/units/isq/si/concentration.h @@ -28,14 +28,15 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { struct mol_per_metre_cub : unit {}; -struct dim_concentration : isq::dim_concentration {}; +struct dim_concentration : + isq::dim_concentration {}; template U, Representation Rep = double> using concentration = quantity; @@ -45,12 +46,16 @@ using concentration = quantity; inline namespace literals { // mol/m³ -constexpr auto operator"" _q_mol_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return concentration(static_cast(l)); } +constexpr auto operator"" _q_mol_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return concentration(static_cast(l)); +} constexpr auto operator"" _q_mol_per_m3(long double l) { return concentration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +63,9 @@ constexpr auto operator"" _q_mol_per_m3(long double l) { return concentration using mol_per_m3 = units::isq::si::concentration; +template +using mol_per_m3 = units::isq::si::concentration; } // namespace units::aliases::isq::si::inline concentration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/conductance.h b/src/systems/si/include/units/isq/si/conductance.h index 50fd7dee..36b8cc13 100644 --- a/src/systems/si/include/units/isq/si/conductance.h +++ b/src/systems/si/include/units/isq/si/conductance.h @@ -29,8 +29,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { @@ -63,76 +63,144 @@ using conductance = quantity; inline namespace literals { // R -constexpr auto operator"" _q_S(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_S(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_S(long double l) { return conductance(l); } // yS -constexpr auto operator"" _q_yS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_yS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_yS(long double l) { return conductance(l); } // zS -constexpr auto operator"" _q_zS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_zS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_zS(long double l) { return conductance(l); } // aS -constexpr auto operator"" _q_aS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_aS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_aS(long double l) { return conductance(l); } // fS -constexpr auto operator"" _q_fS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_fS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_fS(long double l) { return conductance(l); } // pS -constexpr auto operator"" _q_pS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_pS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_pS(long double l) { return conductance(l); } // nS -constexpr auto operator"" _q_nS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_nS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_nS(long double l) { return conductance(l); } // µS -constexpr auto operator"" _q_uS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_uS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_uS(long double l) { return conductance(l); } // mS -constexpr auto operator"" _q_mS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_mS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_mS(long double l) { return conductance(l); } // kS -constexpr auto operator"" _q_kS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_kS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_kS(long double l) { return conductance(l); } // MS -constexpr auto operator"" _q_MS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_MS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_MS(long double l) { return conductance(l); } // GS -constexpr auto operator"" _q_GS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_GS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_GS(long double l) { return conductance(l); } // TS -constexpr auto operator"" _q_TS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_TS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_TS(long double l) { return conductance(l); } // PS -constexpr auto operator"" _q_PS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_PS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_PS(long double l) { return conductance(l); } // ES -constexpr auto operator"" _q_ES(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_ES(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_ES(long double l) { return conductance(l); } // ZS -constexpr auto operator"" _q_ZS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_ZS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_ZS(long double l) { return conductance(l); } // YS -constexpr auto operator"" _q_YS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_YS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_YS(long double l) { return conductance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -164,7 +232,7 @@ using namespace conductance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -172,24 +240,41 @@ using namespace conductance_references; namespace units::aliases::isq::si::inline conductance { -template using S = units::isq::si::conductance; -template using yS = units::isq::si::conductance; -template using zS = units::isq::si::conductance; -template using aS = units::isq::si::conductance; -template using fS = units::isq::si::conductance; -template using pS = units::isq::si::conductance; -template using nS = units::isq::si::conductance; -template using uS = units::isq::si::conductance; -template using mS = units::isq::si::conductance; -template using kS = units::isq::si::conductance; -template using MS = units::isq::si::conductance; -template using GS = units::isq::si::conductance; -template using TS = units::isq::si::conductance; -template using PS = units::isq::si::conductance; -template using ES = units::isq::si::conductance; -template using ZS = units::isq::si::conductance; -template using YS = units::isq::si::conductance; +template +using S = units::isq::si::conductance; +template +using yS = units::isq::si::conductance; +template +using zS = units::isq::si::conductance; +template +using aS = units::isq::si::conductance; +template +using fS = units::isq::si::conductance; +template +using pS = units::isq::si::conductance; +template +using nS = units::isq::si::conductance; +template +using uS = units::isq::si::conductance; +template +using mS = units::isq::si::conductance; +template +using kS = units::isq::si::conductance; +template +using MS = units::isq::si::conductance; +template +using GS = units::isq::si::conductance; +template +using TS = units::isq::si::conductance; +template +using PS = units::isq::si::conductance; +template +using ES = units::isq::si::conductance; +template +using ZS = units::isq::si::conductance; +template +using YS = units::isq::si::conductance; } // namespace units::aliases::isq::si::inline conductance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/density.h b/src/systems/si/include/units/isq/si/density.h index 5b0cf016..9a06b479 100644 --- a/src/systems/si/include/units/isq/si/density.h +++ b/src/systems/si/include/units/isq/si/density.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include #include @@ -47,12 +47,16 @@ using density = quantity; inline namespace literals { // kg / m³ -constexpr auto operator"" _q_kg_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return density(static_cast(l)); } +constexpr auto operator"" _q_kg_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return density(static_cast(l)); +} constexpr auto operator"" _q_kg_per_m3(long double l) { return density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +64,9 @@ constexpr auto operator"" _q_kg_per_m3(long double l) { return density using kg_per_m3 = units::isq::si::density; +template +using kg_per_m3 = units::isq::si::density; } // namespace units::aliases::isq::si::inline density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/energy.h b/src/systems/si/include/units/isq/si/energy.h index 99350d2c..2ca2fc9b 100644 --- a/src/systems/si/include/units/isq/si/energy.h +++ b/src/systems/si/include/units/isq/si/energy.h @@ -53,7 +53,8 @@ struct exajoule : prefixed_unit {}; struct zettajoule : prefixed_unit {}; struct yottajoule : prefixed_unit {}; -// N.B. electron charge (and eV) is an exact constant: https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147 +// N.B. electron charge (and eV) is an exact constant: +// https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147 struct electronvolt : named_scaled_unit {}; struct gigaelectronvolt : prefixed_unit {}; @@ -67,84 +68,160 @@ using energy = quantity; inline namespace literals { // J -constexpr auto operator"" _q_J(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_J(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_J(long double l) { return energy(l); } // yJ -constexpr auto operator"" _q_yJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_yJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_yJ(long double l) { return energy(l); } // zJ -constexpr auto operator"" _q_zJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_zJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_zJ(long double l) { return energy(l); } // aJ -constexpr auto operator"" _q_aJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_aJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_aJ(long double l) { return energy(l); } // fJ -constexpr auto operator"" _q_fJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_fJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_fJ(long double l) { return energy(l); } // pJ -constexpr auto operator"" _q_pJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_pJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_pJ(long double l) { return energy(l); } // nJ -constexpr auto operator"" _q_nJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_nJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_nJ(long double l) { return energy(l); } // uJ -constexpr auto operator"" _q_uJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_uJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_uJ(long double l) { return energy(l); } // mJ -constexpr auto operator"" _q_mJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_mJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_mJ(long double l) { return energy(l); } // kJ -constexpr auto operator"" _q_kJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_kJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_kJ(long double l) { return energy(l); } // MJ -constexpr auto operator"" _q_MJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_MJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_MJ(long double l) { return energy(l); } // GJ -constexpr auto operator"" _q_GJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_GJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_GJ(long double l) { return energy(l); } // TJ -constexpr auto operator"" _q_TJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_TJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_TJ(long double l) { return energy(l); } // PJ -constexpr auto operator"" _q_PJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_PJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_PJ(long double l) { return energy(l); } // EJ -constexpr auto operator"" _q_EJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_EJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_EJ(long double l) { return energy(l); } // ZJ -constexpr auto operator"" _q_ZJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ZJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ZJ(long double l) { return energy(l); } // YJ -constexpr auto operator"" _q_YJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_YJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_YJ(long double l) { return energy(l); } // eV -constexpr auto operator"" _q_eV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_eV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_eV(long double l) { return energy(l); } // GeV -constexpr auto operator"" _q_GeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_GeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_GeV(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -179,7 +256,7 @@ using namespace energy_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -187,27 +264,46 @@ using namespace energy_references; namespace units::aliases::isq::si::inline energy { -template using J = units::isq::si::energy; -template using yJ = units::isq::si::energy; -template using zJ = units::isq::si::energy; -template using aJ = units::isq::si::energy; -template using fJ = units::isq::si::energy; -template using pJ = units::isq::si::energy; -template using nJ = units::isq::si::energy; -template using uJ = units::isq::si::energy; -template using mJ = units::isq::si::energy; -template using kJ = units::isq::si::energy; -template using MJ = units::isq::si::energy; -template using GJ = units::isq::si::energy; -template using TJ = units::isq::si::energy; -template using PJ = units::isq::si::energy; -template using EJ = units::isq::si::energy; -template using ZJ = units::isq::si::energy; -template using YJ = units::isq::si::energy; +template +using J = units::isq::si::energy; +template +using yJ = units::isq::si::energy; +template +using zJ = units::isq::si::energy; +template +using aJ = units::isq::si::energy; +template +using fJ = units::isq::si::energy; +template +using pJ = units::isq::si::energy; +template +using nJ = units::isq::si::energy; +template +using uJ = units::isq::si::energy; +template +using mJ = units::isq::si::energy; +template +using kJ = units::isq::si::energy; +template +using MJ = units::isq::si::energy; +template +using GJ = units::isq::si::energy; +template +using TJ = units::isq::si::energy; +template +using PJ = units::isq::si::energy; +template +using EJ = units::isq::si::energy; +template +using ZJ = units::isq::si::energy; +template +using YJ = units::isq::si::energy; -template using eV = units::isq::si::energy; -template using GeV = units::isq::si::energy; +template +using eV = units::isq::si::energy; +template +using GeV = units::isq::si::energy; } // namespace units::aliases::isq::si::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/force.h b/src/systems/si/include/units/isq/si/force.h index 484e7aeb..c0977aaf 100644 --- a/src/systems/si/include/units/isq/si/force.h +++ b/src/systems/si/include/units/isq/si/force.h @@ -68,92 +68,176 @@ using force = quantity; inline namespace literals { // N -constexpr auto operator"" _q_N(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_N(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_N(long double l) { return force(l); } // yN -constexpr auto operator"" _q_yN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_yN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_yN(long double l) { return force(l); } // zN -constexpr auto operator"" _q_zN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_zN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_zN(long double l) { return force(l); } // aN -constexpr auto operator"" _q_aN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_aN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_aN(long double l) { return force(l); } // fN -constexpr auto operator"" _q_fN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_fN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_fN(long double l) { return force(l); } // pN -constexpr auto operator"" _q_pN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_pN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_pN(long double l) { return force(l); } // nN -constexpr auto operator"" _q_nN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_nN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_nN(long double l) { return force(l); } // uN -constexpr auto operator"" _q_uN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_uN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_uN(long double l) { return force(l); } // mN -constexpr auto operator"" _q_mN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_mN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_mN(long double l) { return force(l); } // cN -constexpr auto operator"" _q_cN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_cN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_cN(long double l) { return force(l); } // dN -constexpr auto operator"" _q_dN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_dN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_dN(long double l) { return force(l); } // daN -constexpr auto operator"" _q_daN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_daN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_daN(long double l) { return force(l); } // hN -constexpr auto operator"" _q_hN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_hN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_hN(long double l) { return force(l); } // kN -constexpr auto operator"" _q_kN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_kN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_kN(long double l) { return force(l); } // MN -constexpr auto operator"" _q_MN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_MN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_MN(long double l) { return force(l); } // GN -constexpr auto operator"" _q_GN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_GN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_GN(long double l) { return force(l); } // TN -constexpr auto operator"" _q_TN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_TN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_TN(long double l) { return force(l); } // PN -constexpr auto operator"" _q_PN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_PN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_PN(long double l) { return force(l); } // EN -constexpr auto operator"" _q_EN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_EN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_EN(long double l) { return force(l); } // ZN -constexpr auto operator"" _q_ZN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_ZN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_ZN(long double l) { return force(l); } // YN -constexpr auto operator"" _q_YN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_YN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_YN(long double l) { return force(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace force_references; namespace units::aliases::isq::si::inline force { -template using N = units::isq::si::force; -template using yN = units::isq::si::force; -template using zN = units::isq::si::force; -template using aN = units::isq::si::force; -template using fN = units::isq::si::force; -template using pN = units::isq::si::force; -template using nN = units::isq::si::force; -template using uN = units::isq::si::force; -template using mN = units::isq::si::force; -template using cN = units::isq::si::force; -template using dN = units::isq::si::force; -template using daN = units::isq::si::force; -template using hN = units::isq::si::force; -template using kN = units::isq::si::force; -template using MN = units::isq::si::force; -template using GN = units::isq::si::force; -template using TN = units::isq::si::force; -template using PN = units::isq::si::force; -template using EN = units::isq::si::force; -template using ZN = units::isq::si::force; -template using YN = units::isq::si::force; +template +using N = units::isq::si::force; +template +using yN = units::isq::si::force; +template +using zN = units::isq::si::force; +template +using aN = units::isq::si::force; +template +using fN = units::isq::si::force; +template +using pN = units::isq::si::force; +template +using nN = units::isq::si::force; +template +using uN = units::isq::si::force; +template +using mN = units::isq::si::force; +template +using cN = units::isq::si::force; +template +using dN = units::isq::si::force; +template +using daN = units::isq::si::force; +template +using hN = units::isq::si::force; +template +using kN = units::isq::si::force; +template +using MN = units::isq::si::force; +template +using GN = units::isq::si::force; +template +using TN = units::isq::si::force; +template +using PN = units::isq::si::force; +template +using EN = units::isq::si::force; +template +using ZN = units::isq::si::force; +template +using YN = units::isq::si::force; } // namespace units::aliases::isq::si::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminance.h b/src/systems/si/include/units/isq/si/luminance.h index d1de3b44..d6c6b74f 100644 --- a/src/systems/si/include/units/isq/si/luminance.h +++ b/src/systems/si/include/units/isq/si/luminance.h @@ -45,12 +45,16 @@ using luminance = quantity; inline namespace literals { // cd/m² -constexpr auto operator"" _q_cd_per_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminance(static_cast(l)); } +constexpr auto operator"" _q_cd_per_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminance(static_cast(l)); +} constexpr auto operator"" _q_cd_per_m2(long double l) { return luminance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +62,9 @@ constexpr auto operator"" _q_cd_per_m2(long double l) { return luminance using cd_per_m2 = units::isq::si::luminance; +template +using cd_per_m2 = units::isq::si::luminance; } // namespace units::aliases::isq::si::inline luminance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminous_intensity.h b/src/systems/si/include/units/isq/si/luminous_intensity.h index 7d0a78ec..e4eff3c5 100644 --- a/src/systems/si/include/units/isq/si/luminous_intensity.h +++ b/src/systems/si/include/units/isq/si/luminous_intensity.h @@ -66,92 +66,176 @@ using luminous_intensity = quantity; inline namespace literals { // cd -constexpr auto operator"" _q_cd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_cd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_cd(long double l) { return luminous_intensity(l); } // ycd -constexpr auto operator"" _q_ycd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ycd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ycd(long double l) { return luminous_intensity(l); } // zcd -constexpr auto operator"" _q_zcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_zcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_zcd(long double l) { return luminous_intensity(l); } // acd -constexpr auto operator"" _q_acd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_acd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_acd(long double l) { return luminous_intensity(l); } // fcd -constexpr auto operator"" _q_fcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_fcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_fcd(long double l) { return luminous_intensity(l); } // pcd -constexpr auto operator"" _q_pcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_pcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_pcd(long double l) { return luminous_intensity(l); } // ncd -constexpr auto operator"" _q_ncd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ncd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ncd(long double l) { return luminous_intensity(l); } // ucd -constexpr auto operator"" _q_ucd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ucd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ucd(long double l) { return luminous_intensity(l); } // mcd -constexpr auto operator"" _q_mcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_mcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_mcd(long double l) { return luminous_intensity(l); } // ccd -constexpr auto operator"" _q_ccd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ccd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ccd(long double l) { return luminous_intensity(l); } // dcd -constexpr auto operator"" _q_dcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_dcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_dcd(long double l) { return luminous_intensity(l); } // dacd -constexpr auto operator"" _q_dacd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_dacd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_dacd(long double l) { return luminous_intensity(l); } // hcd -constexpr auto operator"" _q_hcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_hcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_hcd(long double l) { return luminous_intensity(l); } // kcd -constexpr auto operator"" _q_kcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_kcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_kcd(long double l) { return luminous_intensity(l); } // Mcd -constexpr auto operator"" _q_Mcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Mcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Mcd(long double l) { return luminous_intensity(l); } // Gcd -constexpr auto operator"" _q_Gcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Gcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Gcd(long double l) { return luminous_intensity(l); } // Tcd -constexpr auto operator"" _q_Tcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Tcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Tcd(long double l) { return luminous_intensity(l); } // Pcd -constexpr auto operator"" _q_Pcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Pcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Pcd(long double l) { return luminous_intensity(l); } // Ecd -constexpr auto operator"" _q_Ecd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Ecd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Ecd(long double l) { return luminous_intensity(l); } // Zcd -constexpr auto operator"" _q_Zcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Zcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Zcd(long double l) { return luminous_intensity(l); } // Ycd -constexpr auto operator"" _q_Ycd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Ycd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Ycd(long double l) { return luminous_intensity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -187,7 +271,7 @@ using namespace luminous_intensity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -195,28 +279,49 @@ using namespace luminous_intensity_references; namespace units::aliases::isq::si::luminous_intensity { -template using cd = units::isq::si::luminous_intensity; -template using ycd = units::isq::si::luminous_intensity; -template using zcd = units::isq::si::luminous_intensity; -template using acd = units::isq::si::luminous_intensity; -template using fcd = units::isq::si::luminous_intensity; -template using pcd = units::isq::si::luminous_intensity; -template using ncd = units::isq::si::luminous_intensity; -template using ucd = units::isq::si::luminous_intensity; -template using mcd = units::isq::si::luminous_intensity; -template using ccd = units::isq::si::luminous_intensity; -template using dcd = units::isq::si::luminous_intensity; -template using dacd = units::isq::si::luminous_intensity; -template using hcd = units::isq::si::luminous_intensity; -template using kcd = units::isq::si::luminous_intensity; -template using Mcd = units::isq::si::luminous_intensity; -template using Gcd = units::isq::si::luminous_intensity; -template using Tcd = units::isq::si::luminous_intensity; -template using Pcd = units::isq::si::luminous_intensity; -template using Ecd = units::isq::si::luminous_intensity; -template using Zcd = units::isq::si::luminous_intensity; -template using Ycd = units::isq::si::luminous_intensity; +template +using cd = units::isq::si::luminous_intensity; +template +using ycd = units::isq::si::luminous_intensity; +template +using zcd = units::isq::si::luminous_intensity; +template +using acd = units::isq::si::luminous_intensity; +template +using fcd = units::isq::si::luminous_intensity; +template +using pcd = units::isq::si::luminous_intensity; +template +using ncd = units::isq::si::luminous_intensity; +template +using ucd = units::isq::si::luminous_intensity; +template +using mcd = units::isq::si::luminous_intensity; +template +using ccd = units::isq::si::luminous_intensity; +template +using dcd = units::isq::si::luminous_intensity; +template +using dacd = units::isq::si::luminous_intensity; +template +using hcd = units::isq::si::luminous_intensity; +template +using kcd = units::isq::si::luminous_intensity; +template +using Mcd = units::isq::si::luminous_intensity; +template +using Gcd = units::isq::si::luminous_intensity; +template +using Tcd = units::isq::si::luminous_intensity; +template +using Pcd = units::isq::si::luminous_intensity; +template +using Ecd = units::isq::si::luminous_intensity; +template +using Zcd = units::isq::si::luminous_intensity; +template +using Ycd = units::isq::si::luminous_intensity; } // namespace units::aliases::isq::si::luminous_intensity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/molar_energy.h b/src/systems/si/include/units/isq/si/molar_energy.h index ff1d888e..fa4cae49 100644 --- a/src/systems/si/include/units/isq/si/molar_energy.h +++ b/src/systems/si/include/units/isq/si/molar_energy.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include #include @@ -37,7 +37,8 @@ namespace units::isq::si { struct joule_per_mole : unit {}; -struct dim_molar_energy : isq::dim_molar_energy {}; +struct dim_molar_energy : + isq::dim_molar_energy {}; template U, Representation Rep = double> using molar_energy = quantity; @@ -47,12 +48,16 @@ using molar_energy = quantity; inline namespace literals { // J/mol -constexpr auto operator"" _q_J_per_mol(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return molar_energy(static_cast(l)); } +constexpr auto operator"" _q_J_per_mol(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return molar_energy(static_cast(l)); +} constexpr auto operator"" _q_J_per_mol(long double l) { return molar_energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +65,9 @@ constexpr auto operator"" _q_J_per_mol(long double l) { return molar_energy using J_per_mol = units::isq::si::molar_energy; +template +using J_per_mol = units::isq::si::molar_energy; } // namespace units::aliases::isq::si::inline molar_energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/pressure.h b/src/systems/si/include/units/isq/si/pressure.h index ca0448c7..b3c94279 100644 --- a/src/systems/si/include/units/isq/si/pressure.h +++ b/src/systems/si/include/units/isq/si/pressure.h @@ -68,92 +68,176 @@ using pressure = quantity; inline namespace literals { // Pa -constexpr auto operator"" _q_Pa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_Pa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_Pa(long double l) { return pressure(l); } // yPa -constexpr auto operator"" _q_yPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_yPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_yPa(long double l) { return pressure(l); } // zPa -constexpr auto operator"" _q_zPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_zPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_zPa(long double l) { return pressure(l); } // aPa -constexpr auto operator"" _q_aPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_aPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_aPa(long double l) { return pressure(l); } // fPa -constexpr auto operator"" _q_fPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_fPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_fPa(long double l) { return pressure(l); } // pPa -constexpr auto operator"" _q_pPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_pPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_pPa(long double l) { return pressure(l); } // nPa -constexpr auto operator"" _q_nPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_nPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_nPa(long double l) { return pressure(l); } // uPa -constexpr auto operator"" _q_uPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_uPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_uPa(long double l) { return pressure(l); } // mPa -constexpr auto operator"" _q_mPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_mPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_mPa(long double l) { return pressure(l); } // cPa -constexpr auto operator"" _q_cPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_cPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_cPa(long double l) { return pressure(l); } // dPa -constexpr auto operator"" _q_dPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_dPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_dPa(long double l) { return pressure(l); } // daPa -constexpr auto operator"" _q_daPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_daPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_daPa(long double l) { return pressure(l); } // hPa -constexpr auto operator"" _q_hPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_hPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_hPa(long double l) { return pressure(l); } // kPa -constexpr auto operator"" _q_kPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_kPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_kPa(long double l) { return pressure(l); } // MPa -constexpr auto operator"" _q_MPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_MPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_MPa(long double l) { return pressure(l); } // GPa -constexpr auto operator"" _q_GPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_GPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_GPa(long double l) { return pressure(l); } // TPa -constexpr auto operator"" _q_TPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_TPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_TPa(long double l) { return pressure(l); } // PPa -constexpr auto operator"" _q_PPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_PPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_PPa(long double l) { return pressure(l); } // EPa -constexpr auto operator"" _q_EPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_EPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_EPa(long double l) { return pressure(l); } // ZPa -constexpr auto operator"" _q_ZPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_ZPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_ZPa(long double l) { return pressure(l); } // YPa -constexpr auto operator"" _q_YPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_YPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_YPa(long double l) { return pressure(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace pressure_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace pressure_references; namespace units::aliases::isq::si::inline pressure { -template using Pa = units::isq::si::pressure; -template using yPa = units::isq::si::pressure; -template using zPa = units::isq::si::pressure; -template using aPa = units::isq::si::pressure; -template using fPa = units::isq::si::pressure; -template using pPa = units::isq::si::pressure; -template using nPa = units::isq::si::pressure; -template using uPa = units::isq::si::pressure; -template using mPa = units::isq::si::pressure; -template using cPa = units::isq::si::pressure; -template using dPa = units::isq::si::pressure; -template using daPa = units::isq::si::pressure; -template using hPa = units::isq::si::pressure; -template using kPa = units::isq::si::pressure; -template using MPa = units::isq::si::pressure; -template using GPa = units::isq::si::pressure; -template using TPa = units::isq::si::pressure; -template using PPa = units::isq::si::pressure; -template using EPa = units::isq::si::pressure; -template using ZPa = units::isq::si::pressure; -template using YPa = units::isq::si::pressure; +template +using Pa = units::isq::si::pressure; +template +using yPa = units::isq::si::pressure; +template +using zPa = units::isq::si::pressure; +template +using aPa = units::isq::si::pressure; +template +using fPa = units::isq::si::pressure; +template +using pPa = units::isq::si::pressure; +template +using nPa = units::isq::si::pressure; +template +using uPa = units::isq::si::pressure; +template +using mPa = units::isq::si::pressure; +template +using cPa = units::isq::si::pressure; +template +using dPa = units::isq::si::pressure; +template +using daPa = units::isq::si::pressure; +template +using hPa = units::isq::si::pressure; +template +using kPa = units::isq::si::pressure; +template +using MPa = units::isq::si::pressure; +template +using GPa = units::isq::si::pressure; +template +using TPa = units::isq::si::pressure; +template +using PPa = units::isq::si::pressure; +template +using EPa = units::isq::si::pressure; +template +using ZPa = units::isq::si::pressure; +template +using YPa = units::isq::si::pressure; } // namespace units::aliases::isq::si::inline pressure -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/radioactivity.h b/src/systems/si/include/units/isq/si/radioactivity.h index 2c2c8dc3..017d8fcf 100644 --- a/src/systems/si/include/units/isq/si/radioactivity.h +++ b/src/systems/si/include/units/isq/si/radioactivity.h @@ -66,92 +66,176 @@ using radioactivity = quantity; inline namespace literals { // Bq -constexpr auto operator"" _q_Bq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_Bq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_Bq(long double l) { return radioactivity(l); } // yBq -constexpr auto operator"" _q_yBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_yBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_yBq(long double l) { return radioactivity(l); } // zBq -constexpr auto operator"" _q_zBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_zBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_zBq(long double l) { return radioactivity(l); } // aBq -constexpr auto operator"" _q_aBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_aBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_aBq(long double l) { return radioactivity(l); } // fBq -constexpr auto operator"" _q_fBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_fBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_fBq(long double l) { return radioactivity(l); } // pBq -constexpr auto operator"" _q_pBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_pBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_pBq(long double l) { return radioactivity(l); } // nBq -constexpr auto operator"" _q_nBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_nBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_nBq(long double l) { return radioactivity(l); } // uBq -constexpr auto operator"" _q_uBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_uBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_uBq(long double l) { return radioactivity(l); } // mBq -constexpr auto operator"" _q_mBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_mBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_mBq(long double l) { return radioactivity(l); } // cBq -constexpr auto operator"" _q_cBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_cBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_cBq(long double l) { return radioactivity(l); } // dBq -constexpr auto operator"" _q_dBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_dBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_dBq(long double l) { return radioactivity(l); } // daBq -constexpr auto operator"" _q_daBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_daBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_daBq(long double l) { return radioactivity(l); } // hBq -constexpr auto operator"" _q_hBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_hBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_hBq(long double l) { return radioactivity(l); } // kBq -constexpr auto operator"" _q_kBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_kBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_kBq(long double l) { return radioactivity(l); } // MBq -constexpr auto operator"" _q_MBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_MBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_MBq(long double l) { return radioactivity(l); } // GBq -constexpr auto operator"" _q_GBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_GBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_GBq(long double l) { return radioactivity(l); } // TBq -constexpr auto operator"" _q_TBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_TBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_TBq(long double l) { return radioactivity(l); } // PBq -constexpr auto operator"" _q_PBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_PBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_PBq(long double l) { return radioactivity(l); } // EBq -constexpr auto operator"" _q_EBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_EBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_EBq(long double l) { return radioactivity(l); } // ZBq -constexpr auto operator"" _q_ZBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_ZBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_ZBq(long double l) { return radioactivity(l); } // YBq -constexpr auto operator"" _q_YBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_YBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_YBq(long double l) { return radioactivity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -187,7 +271,7 @@ using namespace radioactivity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -195,28 +279,49 @@ using namespace radioactivity_references; namespace units::aliases::isq::si::inline radioactivity { -template using Bq = units::isq::radioactivity; -template using yBq = units::isq::radioactivity; -template using zBq = units::isq::radioactivity; -template using aBq = units::isq::radioactivity; -template using fBq = units::isq::radioactivity; -template using pBq = units::isq::radioactivity; -template using nBq = units::isq::radioactivity; -template using uBq = units::isq::radioactivity; -template using mBq = units::isq::radioactivity; -template using cBq = units::isq::radioactivity; -template using dBq = units::isq::radioactivity; -template using daBq = units::isq::radioactivity; -template using hBq = units::isq::radioactivity; -template using kBq = units::isq::radioactivity; -template using MBq = units::isq::radioactivity; -template using GBq = units::isq::radioactivity; -template using TBq = units::isq::radioactivity; -template using PBq = units::isq::radioactivity; -template using EBq = units::isq::radioactivity; -template using ZBq = units::isq::radioactivity; -template using YBq = units::isq::radioactivity; +template +using Bq = units::isq::radioactivity; +template +using yBq = units::isq::radioactivity; +template +using zBq = units::isq::radioactivity; +template +using aBq = units::isq::radioactivity; +template +using fBq = units::isq::radioactivity; +template +using pBq = units::isq::radioactivity; +template +using nBq = units::isq::radioactivity; +template +using uBq = units::isq::radioactivity; +template +using mBq = units::isq::radioactivity; +template +using cBq = units::isq::radioactivity; +template +using dBq = units::isq::radioactivity; +template +using daBq = units::isq::radioactivity; +template +using hBq = units::isq::radioactivity; +template +using kBq = units::isq::radioactivity; +template +using MBq = units::isq::radioactivity; +template +using GBq = units::isq::radioactivity; +template +using TBq = units::isq::radioactivity; +template +using PBq = units::isq::radioactivity; +template +using EBq = units::isq::radioactivity; +template +using ZBq = units::isq::radioactivity; +template +using YBq = units::isq::radioactivity; } // namespace units::aliases::isq::si::inline radioactivity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/voltage.h b/src/systems/si/include/units/isq/si/voltage.h index 8f10478f..31922688 100644 --- a/src/systems/si/include/units/isq/si/voltage.h +++ b/src/systems/si/include/units/isq/si/voltage.h @@ -68,92 +68,176 @@ using voltage = quantity; inline namespace literals { // V -constexpr auto operator"" _q_V(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_V(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_V(long double l) { return voltage(l); } // yV -constexpr auto operator"" _q_yV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_yV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_yV(long double l) { return voltage(l); } // zV -constexpr auto operator"" _q_zV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_zV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_zV(long double l) { return voltage(l); } // aV -constexpr auto operator"" _q_aV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_aV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_aV(long double l) { return voltage(l); } // fV -constexpr auto operator"" _q_fV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_fV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_fV(long double l) { return voltage(l); } // pV -constexpr auto operator"" _q_pV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_pV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_pV(long double l) { return voltage(l); } // nV -constexpr auto operator"" _q_nV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_nV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_nV(long double l) { return voltage(l); } // uV -constexpr auto operator"" _q_uV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_uV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_uV(long double l) { return voltage(l); } // mV -constexpr auto operator"" _q_mV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_mV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_mV(long double l) { return voltage(l); } // cV -constexpr auto operator"" _q_cV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_cV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_cV(long double l) { return voltage(l); } // dV -constexpr auto operator"" _q_dV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_dV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_dV(long double l) { return voltage(l); } // daV -constexpr auto operator"" _q_daV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_daV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_daV(long double l) { return voltage(l); } // hV -constexpr auto operator"" _q_hV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_hV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_hV(long double l) { return voltage(l); } // kV -constexpr auto operator"" _q_kV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_kV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_kV(long double l) { return voltage(l); } // MV -constexpr auto operator"" _q_MV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_MV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_MV(long double l) { return voltage(l); } // GV -constexpr auto operator"" _q_GV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_GV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_GV(long double l) { return voltage(l); } // TV -constexpr auto operator"" _q_TV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_TV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_TV(long double l) { return voltage(l); } // PV -constexpr auto operator"" _q_PV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_PV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_PV(long double l) { return voltage(l); } // EV -constexpr auto operator"" _q_EV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_EV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_EV(long double l) { return voltage(l); } // ZV -constexpr auto operator"" _q_ZV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_ZV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_ZV(long double l) { return voltage(l); } // YV -constexpr auto operator"" _q_YV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_YV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_YV(long double l) { return voltage(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace voltage_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace voltage_references; namespace units::aliases::isq::si::inline voltage { -template using V = units::isq::si::voltage; -template using yV = units::isq::si::voltage; -template using zV = units::isq::si::voltage; -template using aV = units::isq::si::voltage; -template using fV = units::isq::si::voltage; -template using pV = units::isq::si::voltage; -template using nV = units::isq::si::voltage; -template using uV = units::isq::si::voltage; -template using mV = units::isq::si::voltage; -template using cV = units::isq::si::voltage; -template using dV = units::isq::si::voltage; -template using daV = units::isq::si::voltage; -template using hV = units::isq::si::voltage; -template using kV = units::isq::si::voltage; -template using MV = units::isq::si::voltage; -template using GV = units::isq::si::voltage; -template using TV = units::isq::si::voltage; -template using PV = units::isq::si::voltage; -template using EV = units::isq::si::voltage; -template using ZV = units::isq::si::voltage; -template using YV = units::isq::si::voltage; +template +using V = units::isq::si::voltage; +template +using yV = units::isq::si::voltage; +template +using zV = units::isq::si::voltage; +template +using aV = units::isq::si::voltage; +template +using fV = units::isq::si::voltage; +template +using pV = units::isq::si::voltage; +template +using nV = units::isq::si::voltage; +template +using uV = units::isq::si::voltage; +template +using mV = units::isq::si::voltage; +template +using cV = units::isq::si::voltage; +template +using dV = units::isq::si::voltage; +template +using daV = units::isq::si::voltage; +template +using hV = units::isq::si::voltage; +template +using kV = units::isq::si::voltage; +template +using MV = units::isq::si::voltage; +template +using GV = units::isq::si::voltage; +template +using TV = units::isq::si::voltage; +template +using PV = units::isq::si::voltage; +template +using EV = units::isq::si::voltage; +template +using ZV = units::isq::si::voltage; +template +using YV = units::isq::si::voltage; } // namespace units::aliases::isq::si::inline voltage -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/test/metabench/list/type_list_concepts_all.h b/test/metabench/list/type_list_concepts_all.h index 62255427..d7523912 100644 --- a/test/metabench/list/type_list_concepts_all.h +++ b/test/metabench/list/type_list_concepts_all.h @@ -26,160 +26,159 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - template - using conditional_t = conditional::template type; +template +using conditional_t = conditional::template type; - } +} // namespace detail - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - template - struct type_list_push_front; +template +struct type_list_push_front; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front, NewTypes...> { + using type = List; +}; - template - using type_list_push_front_t = type_list_push_front::type; +template +using type_list_push_front_t = type_list_push_front::type; - // push_back +// push_back - template - struct type_list_push_back; +template +struct type_list_push_back; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back, NewTypes...> { + using type = List; +}; - template - using type_list_push_back_t = type_list_push_back::type; +template +using type_list_push_back_t = type_list_push_back::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using base_first = base::first_list; - using base_second = base::second_list; - using first_list = detail::conditional_t, base_first>; - using second_list = detail::conditional_t>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using base_first = base::first_list; + using base_second = base::second_list; + using first_list = detail::conditional_t < Idx, base_first>; + using second_list = detail::conditional_t < Idx>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - template typename Pred> - struct type_list_merge_sorted; +template typename Pred> +struct type_list_merge_sorted; - template typename Pred> - using type_list_merge_sorted_t = type_list_merge_sorted::type; +template typename Pred> +using type_list_merge_sorted_t = type_list_merge_sorted::type; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted, List, Pred> { - using type = detail::conditional_t< - Pred::value, - type_list_push_front_t, List, Pred>, Lhs1>, - type_list_push_front_t, List, Pred>, Rhs1>>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted, List, Pred> { + using type = detail::conditional_t< + Pred::value, + type_list_push_front_t, List, Pred>, Lhs1>, + type_list_push_front_t, List, Pred>, Rhs1>>; +}; - // sort +// sort - template typename Pred> - struct type_list_sort; +template typename Pred> +struct type_list_sort; - template typename List, template typename Pred> - struct type_list_sort, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort::type; - using right = type_list_sort::type; - using type = type_list_merge_sorted_t; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort::type; + using right = type_list_sort::type; + using type = type_list_merge_sorted_t; +}; - template typename Pred> - using type_list_sort_t = type_list_sort::type; +template typename Pred> +using type_list_sort_t = type_list_sort::type; } // namespace units diff --git a/test/metabench/list/type_list_concepts_iface.h b/test/metabench/list/type_list_concepts_iface.h index 33d4af86..b30478cb 100644 --- a/test/metabench/list/type_list_concepts_iface.h +++ b/test/metabench/list/type_list_concepts_iface.h @@ -26,179 +26,180 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_concepts_no.h b/test/metabench/list/type_list_concepts_no.h index ab74a04e..4f480405 100644 --- a/test/metabench/list/type_list_concepts_no.h +++ b/test/metabench/list/type_list_concepts_no.h @@ -26,166 +26,167 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_alias.h b/test/metabench/list/type_list_conditional_alias.h index 33d4af86..b30478cb 100644 --- a/test/metabench/list/type_list_conditional_alias.h +++ b/test/metabench/list/type_list_conditional_alias.h @@ -26,179 +26,180 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_alias_hard.h b/test/metabench/list/type_list_conditional_alias_hard.h index b2b9db39..e81eb85c 100644 --- a/test/metabench/list/type_list_conditional_alias_hard.h +++ b/test/metabench/list/type_list_conditional_alias_hard.h @@ -26,172 +26,172 @@ namespace units { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::template type< - typename type_list_push_front_impl::type, - typename base::first_list>; - using second_list = conditional::template type< - typename base::second_list, - typename type_list_push_front_impl::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < Idx::template type::type, + typename base::first_list>; + using second_list = + conditional < Idx::template type::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value>::template type< - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional::value>::template type< + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_std.h b/test/metabench/list/type_list_conditional_std.h index 8626aee2..84c4fce3 100644 --- a/test/metabench/list/type_list_conditional_std.h +++ b/test/metabench/list/type_list_conditional_std.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = std::conditional_t::type, - typename base::first_list>; - using second_list = std::conditional_t::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + std::conditional_t < + Idx::type, typename base::first_list>; + using second_list = + std::conditional_t < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = std::conditional_t< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = std::conditional_t< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_concepts_all.h b/test/metabench/make_dimension/dimension_concepts_all.h index 2833a82c..7d9ae1f0 100644 --- a/test/metabench/make_dimension/dimension_concepts_all.h +++ b/test/metabench/make_dimension/dimension_concepts_all.h @@ -22,193 +22,190 @@ #pragma once -#include "type_list_concepts_all.h" #include "downcasting_concepts_all.h" #include "ratio_concepts_all.h" +#include "type_list_concepts_all.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr std::intmax_t num = Num; + static constexpr std::intmax_t den = Den; +}; - // is_exponent - namespace detail { - template - inline constexpr bool is_exponent = false; +// is_exponent +namespace detail { +template +inline constexpr bool is_exponent = false; - template - inline constexpr bool is_exponent> = true; - } // namespace detail +template +inline constexpr bool is_exponent> = true; +} // namespace detail - template - concept Exponent = detail::is_exponent; +template +concept Exponent = detail::is_exponent; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // is_dimension - namespace detail { +// is_dimension +namespace detail { - template - inline constexpr bool is_dimension = false; +template +inline constexpr bool is_dimension = false; - template - inline constexpr bool is_dimension> = true; +template +inline constexpr bool is_dimension> = true; - } // namespace detail +} // namespace detail - template - concept Dimension = - std::is_empty_v && - detail::is_dimension>; +template +concept Dimension = std::is_empty_v && detail::is_dimension>; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_concepts_iface.h b/test/metabench/make_dimension/dimension_concepts_iface.h index 3142bd2a..44b20ce5 100644 --- a/test/metabench/make_dimension/dimension_concepts_iface.h +++ b/test/metabench/make_dimension/dimension_concepts_iface.h @@ -22,193 +22,190 @@ #pragma once -#include "type_list_concepts_iface.h" #include "downcasting_concepts_all.h" #include "ratio_concepts_iface.h" +#include "type_list_concepts_iface.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr int num = Num; - static constexpr int den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr int num = Num; + static constexpr int den = Den; +}; - // is_exponent - namespace detail { - template - inline constexpr bool is_exponent = false; +// is_exponent +namespace detail { +template +inline constexpr bool is_exponent = false; - template - inline constexpr bool is_exponent> = true; - } // namespace detail +template +inline constexpr bool is_exponent> = true; +} // namespace detail - template - concept Exponent = detail::is_exponent; +template +concept Exponent = detail::is_exponent; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // is_dimension - namespace detail { +// is_dimension +namespace detail { - template - inline constexpr bool is_dimension = false; +template +inline constexpr bool is_dimension = false; - template - inline constexpr bool is_dimension> = true; +template +inline constexpr bool is_dimension> = true; - } // namespace detail +} // namespace detail - template - concept Dimension = - std::is_empty_v && - detail::is_dimension>; +template +concept Dimension = std::is_empty_v && detail::is_dimension>; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_no_concepts.h b/test/metabench/make_dimension/dimension_no_concepts.h index f8b0de38..d8706535 100644 --- a/test/metabench/make_dimension/dimension_no_concepts.h +++ b/test/metabench/make_dimension/dimension_no_concepts.h @@ -22,164 +22,163 @@ #pragma once -#include "type_list_no_concepts.h" #include "downcasting_no_concepts.h" #include "ratio_no_concepts.h" +#include "type_list_no_concepts.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr std::intmax_t num = Num; + static constexpr std::intmax_t den = Den; +}; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/downcasting_concepts_all.h b/test/metabench/make_dimension/downcasting_concepts_all.h index 68bd5230..c08161c9 100644 --- a/test/metabench/make_dimension/downcasting_concepts_all.h +++ b/test/metabench/make_dimension/downcasting_concepts_all.h @@ -27,25 +27,22 @@ namespace units { - template - struct downcast_base { - using downcast_base_type = BaseType; - }; +template +struct downcast_base { + using downcast_base_type = BaseType; +}; - template - concept Downcastable = - requires { - typename T::downcast_base_type; - } && - std::derived_from>; +template +concept Downcastable = + requires { typename T::downcast_base_type; } && std::derived_from>; - template - using downcast_base_t = T::downcast_base_type; +template +using downcast_base_t = T::downcast_base_type; - template - struct downcast_traits : std::type_identity {}; +template +struct downcast_traits : std::type_identity {}; - template - using downcast_traits_t = downcast_traits::type; +template +using downcast_traits_t = downcast_traits::type; } // namespace units diff --git a/test/metabench/make_dimension/downcasting_no_concepts.h b/test/metabench/make_dimension/downcasting_no_concepts.h index 051b0ff5..8b7bec8f 100644 --- a/test/metabench/make_dimension/downcasting_no_concepts.h +++ b/test/metabench/make_dimension/downcasting_no_concepts.h @@ -27,18 +27,18 @@ namespace units { - template - struct downcast_base { - using downcast_base_type = BaseType; - }; +template +struct downcast_base { + using downcast_base_type = BaseType; +}; - template - using downcast_base_t = T::downcast_base_type; +template +using downcast_base_t = T::downcast_base_type; - template - struct downcast_traits : std::type_identity {}; +template +struct downcast_traits : std::type_identity {}; - template - using downcast_traits_t = downcast_traits::type; +template +using downcast_traits_t = downcast_traits::type; } // namespace units diff --git a/test/metabench/make_dimension/hacks.h b/test/metabench/make_dimension/hacks.h index 88b24a11..b95278a9 100644 --- a/test/metabench/make_dimension/hacks.h +++ b/test/metabench/make_dimension/hacks.h @@ -26,11 +26,11 @@ namespace std { - // concepts - using concepts::same_as; - using concepts::derived_from; - using concepts::regular; - using concepts::totally_ordered; - using concepts::convertible_to; +// concepts +using concepts::convertible_to; +using concepts::derived_from; +using concepts::regular; +using concepts::same_as; +using concepts::totally_ordered; -} +} // namespace std diff --git a/test/metabench/make_dimension/ratio_concepts_all.h b/test/metabench/make_dimension/ratio_concepts_all.h index e9aaf95e..344a8511 100644 --- a/test/metabench/make_dimension/ratio_concepts_all.h +++ b/test/metabench/make_dimension/ratio_concepts_all.h @@ -23,115 +23,118 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // is_ratio +// is_ratio - namespace detail { +namespace detail { - template - inline constexpr bool is_ratio = false; +template +inline constexpr bool is_ratio = false; - template - inline constexpr bool is_ratio> = true; +template +inline constexpr bool is_ratio> = true; - } // namespace detail +} // namespace detail - template - concept Ratio = detail::is_ratio; +template +concept Ratio = detail::is_ratio; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/ratio_concepts_iface.h b/test/metabench/make_dimension/ratio_concepts_iface.h index e6e5d169..fe59c2ca 100644 --- a/test/metabench/make_dimension/ratio_concepts_iface.h +++ b/test/metabench/make_dimension/ratio_concepts_iface.h @@ -23,115 +23,118 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // is_ratio +// is_ratio - namespace detail { +namespace detail { - template - inline constexpr bool is_ratio = false; +template +inline constexpr bool is_ratio = false; - template - inline constexpr bool is_ratio> = true; +template +inline constexpr bool is_ratio> = true; - } // namespace detail +} // namespace detail - template - concept Ratio = detail::is_ratio; +template +concept Ratio = detail::is_ratio; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/ratio_no_concepts.h b/test/metabench/make_dimension/ratio_no_concepts.h index db11488e..fa1b7ba9 100644 --- a/test/metabench/make_dimension/ratio_no_concepts.h +++ b/test/metabench/make_dimension/ratio_no_concepts.h @@ -23,100 +23,103 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_all.h b/test/metabench/make_dimension/type_list_concepts_all.h index 2195496c..80392b3e 100644 --- a/test/metabench/make_dimension/type_list_concepts_all.h +++ b/test/metabench/make_dimension/type_list_concepts_all.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_iface.h b/test/metabench/make_dimension/type_list_concepts_iface.h index 711b8556..0737c88b 100644 --- a/test/metabench/make_dimension/type_list_concepts_iface.h +++ b/test/metabench/make_dimension/type_list_concepts_iface.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_no_concepts.h b/test/metabench/make_dimension/type_list_no_concepts.h index c17fda5d..82e40f40 100644 --- a/test/metabench/make_dimension/type_list_no_concepts.h +++ b/test/metabench/make_dimension/type_list_no_concepts.h @@ -26,147 +26,148 @@ namespace units { - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_traits.h b/test/metabench/make_dimension/type_traits.h index 842410f3..35d7e162 100644 --- a/test/metabench/make_dimension/type_traits.h +++ b/test/metabench/make_dimension/type_traits.h @@ -26,23 +26,23 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional_impl { - template - using type = F; - }; +template +struct conditional_impl { + template + using type = F; +}; - template<> - struct conditional_impl { - template - using type = T; - }; +template<> +struct conditional_impl { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = TYPENAME detail::conditional_impl::template type; +template +using conditional = TYPENAME detail::conditional_impl::template type; -} +} // namespace units diff --git a/test/metabench/ratio/ratio_type_constexpr.h b/test/metabench/ratio/ratio_type_constexpr.h index 26dc31b3..86e2c0d6 100644 --- a/test/metabench/ratio/ratio_type_constexpr.h +++ b/test/metabench/ratio/ratio_type_constexpr.h @@ -22,103 +22,107 @@ #pragma once -#include -#include -#include #include +#include +#include +#include -#define Expects(cond) if(!(cond)) ::std::terminate(); +#define Expects(cond) \ + if (!(cond)) ::std::terminate(); namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = typename detail::ratio_multiply::type; +template +using ratio_multiply = typename detail::ratio_multiply::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = typename detail::ratio_divide::type; +template +using ratio_divide = typename detail::ratio_divide::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio_t = typename detail::common_ratio_impl::type; +template +using common_ratio_t = typename detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/ratio/std_ratio.h b/test/metabench/ratio/std_ratio.h index 6c1a13f2..459b5acd 100644 --- a/test/metabench/ratio/std_ratio.h +++ b/test/metabench/ratio/std_ratio.h @@ -27,42 +27,37 @@ namespace units { - // static_sign +// static_sign - template - struct static_sign : std::integral_constant { - }; +template +struct static_sign : std::integral_constant {}; - // static_abs +// static_abs - template - struct static_abs : std::integral_constant::value> { - }; +template +struct static_abs : std::integral_constant::value> {}; - // static_gcd +// static_gcd - template - struct static_gcd : static_gcd { - }; +template +struct static_gcd : static_gcd {}; - template - struct static_gcd : std::integral_constant::value> { - }; +template +struct static_gcd : std::integral_constant::value> {}; - template - struct static_gcd<0, Qn> : std::integral_constant::value> { - }; +template +struct static_gcd<0, Qn> : std::integral_constant::value> {}; - // common_ratio +// common_ratio - template - struct common_ratio { - using gcd_num = static_gcd; - using gcd_den = static_gcd; - using type = std::ratio; - }; +template +struct common_ratio { + using gcd_num = static_gcd; + using gcd_den = static_gcd; + using type = std::ratio; +}; - template - using common_ratio_t = typename common_ratio::type; +template +using common_ratio_t = typename common_ratio::type; } // namespace units diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index fbde0bfe..2b237250 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -67,19 +67,22 @@ static_assert(!Speed>); static_assert(Acceleration>); static_assert(!Acceleration>); #if UNITS_DOWNCAST_MODE == 0 -static_assert(Acceleration, exponent>, unknown_coherent_unit>>); +static_assert(Acceleration, exponent>, + unknown_coherent_unit>>); #endif static_assert(Force>); static_assert(!Force>); #if UNITS_DOWNCAST_MODE == 0 -// static_assert(Force, exponent, exponent>, unknown_coherent_unit>>); +// static_assert(Force, exponent, +// exponent>, unknown_coherent_unit>>); #endif static_assert(Energy>); static_assert(!Energy>); #if UNITS_DOWNCAST_MODE == 0 -// static_assert(Energy, exponent, exponent>, unknown_coherent_unit>>); +// static_assert(Energy, exponent, +// exponent>, unknown_coherent_unit>>); #endif static_assert(Power>); @@ -168,4 +171,4 @@ static_assert(!Permeability>); static_assert(MolarEnergy>); static_assert(!MolarEnergy>); -} +} // namespace diff --git a/test/unit_test/static/fixed_string_test.cpp b/test/unit_test/static/fixed_string_test.cpp index 8fadd9d7..7c4ffeb2 100644 --- a/test/unit_test/static/fixed_string_test.cpp +++ b/test/unit_test/static/fixed_string_test.cpp @@ -50,4 +50,4 @@ static_assert(basic_fixed_string('d') + txt2 == basic_fixed_string("dabc")); static_assert(txt2 + basic_fixed_string("def") == basic_fixed_string("abcdef")); static_assert(basic_fixed_string("def") + txt2 == basic_fixed_string("defabc")); -} +} // namespace diff --git a/test/unit_test/static/fps_test.cpp b/test/unit_test/static/fps_test.cpp index 74ddd60e..8f241525 100644 --- a/test/unit_test/static/fps_test.cpp +++ b/test/unit_test/static/fps_test.cpp @@ -100,6 +100,7 @@ static_assert(1_q_ft_pdl_per_s * 10_q_s == 10_q_ft_pdl); static_assert(10_q_ft_pdl / 1_q_ft_pdl_per_s == 10_q_s); static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ pdl/s", "ft pdl/s")); -static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s")); +static_assert(detail::unit_text() == + basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s")); -} +} // namespace diff --git a/test/unit_test/static/quantity_kind_test.cpp b/test/unit_test/static/quantity_kind_test.cpp index d9dc2961..adbfeb8d 100644 --- a/test/unit_test/static/quantity_kind_test.cpp +++ b/test/unit_test/static/quantity_kind_test.cpp @@ -114,7 +114,7 @@ concept invalid_types = requires { requires !requires { typename quantity_kind; }; // unit of a different dimension requires !requires { typename quantity_kind>; }; // quantity used as Rep - requires !requires { // quantity point used as Rep + requires !requires { // quantity point used as Rep typename quantity_kind, metre>>; }; requires !requires { typename quantity_kind>; }; // quantity kind used as Rep diff --git a/test/unit_test/static/quantity_point_test.cpp b/test/unit_test/static/quantity_point_test.cpp index 19b6e32f..8eb42c4c 100644 --- a/test/unit_test/static/quantity_point_test.cpp +++ b/test/unit_test/static/quantity_point_test.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include "test_tools.h" #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -46,20 +46,22 @@ struct sea_level_origin : point_origin {}; // class invariants template -concept invalid_types = requires -{ - // unit of a different dimension: - requires !requires { typename quantity_point, second, int>; }; - // quantity used as Rep: - requires !requires { typename quantity_point, metre, quantity>; }; - // quantity point used as Rep: - requires !requires { typename quantity_point, metre, - quantity_point, metre, int>>; }; - // reordered arguments: - requires !requires { typename quantity_point, double>; }; - // dimension used as origin: - requires !requires { typename quantity_point; }; -}; +concept invalid_types = + requires { + // unit of a different dimension: + requires !requires { typename quantity_point, second, int>; }; + // quantity used as Rep: + requires !requires { typename quantity_point, metre, quantity>; }; + // quantity point used as Rep: + requires !requires { + typename quantity_point, metre, + quantity_point, metre, int>>; + }; + // reordered arguments: + requires !requires { typename quantity_point, double>; }; + // dimension used as origin: + requires !requires { typename quantity_point; }; + }; static_assert(invalid_types); @@ -71,7 +73,8 @@ static_assert(is_same_v, metre, int>:: static_assert(is_same_v, kilometre, int>::unit, kilometre>); static_assert(is_same_v, metre, int>::dimension, dim_length>); static_assert(is_same_v, metre, int>::origin, dynamic_origin>); -static_assert(is_same_v, metre, int>::quantity_type, quantity>); +static_assert( + is_same_v, metre, int>::quantity_type, quantity>); // constructors @@ -80,10 +83,14 @@ static_assert(!std::is_convertible_v static_assert(quantity_point(42s).relative() == 42 * s); static_assert(quantity_point(sys_seconds{42s}).relative() == 42 * s); -static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); -static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); +static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); +static_assert( + !std::is_convertible_v, second, std::chrono::seconds::rep>>); static_assert(!std::is_convertible_v, second, sys_seconds::rep>>); -static_assert(!std::is_convertible_v, second, sys_seconds::rep>>); +static_assert(!std::is_convertible_v< + sys_seconds, quantity_point, second, sys_seconds::rep>>); static_assert(quantity_point, metre, int>().relative() == 0_q_m); constexpr quantity_point, metre, int> km{1000_q_m}; @@ -91,21 +98,25 @@ static_assert(km.relative() == 1000_q_m); static_assert(quantity_point, metre, int>(km).relative() == km.relative()); static_assert(quantity_point, metre, int>(1_q_m).relative() == 1_q_m); -static_assert(!std::is_constructible_v, metre, int>, double>); // truncating conversion +static_assert( + !std::is_constructible_v, metre, int>, double>); // truncating conversion static_assert(quantity_point, metre, double>(1.0_q_m).relative() == 1.0_q_m); static_assert(quantity_point, metre, double>(1_q_m).relative() == 1_q_m); static_assert(quantity_point, metre, long double>(3.14_q_m).relative() == 3.14_q_m); static_assert(quantity_point, metre, int>(km).relative() == 1000_q_m); -static_assert(!std::is_constructible_v, metre, int>, - quantity_point, metre, double>>); // truncating conversion -static_assert(quantity_point, metre, double>(quantity_point(1000.0_q_m)).relative() == 1000.0_q_m); +static_assert( + !std::is_constructible_v, metre, int>, + quantity_point, metre, double>>); // truncating conversion +static_assert(quantity_point, metre, double>(quantity_point(1000.0_q_m)).relative() == + 1000.0_q_m); static_assert(quantity_point, metre, double>(km).relative() == 1000.0_q_m); static_assert(quantity_point, metre, int>(quantity_point(1_q_km)).relative() == 1000_q_m); static_assert(!std::is_constructible_v, metre, int>, quantity_point, second, int>>); // different dimensions -static_assert(!std::is_constructible_v, kilometre, int>, - quantity_point, metre, int>>); // truncating conversion +static_assert( + !std::is_constructible_v, kilometre, int>, + quantity_point, metre, int>>); // truncating conversion static_assert(!std::is_constructible_v, quantity_point, metre, int>>, @@ -115,12 +126,18 @@ static_assert(!std::is_constructible_v, // assignment operator -static_assert([]() { quantity_point, metre, int> l1(1_q_m), l2{}; return l2 = l1; }().relative() == 1_q_m); +static_assert(([]() { + quantity_point, metre, int> l1(1_q_m), l2{}; + return l2 = l1; + }()) + .relative() == 1_q_m); // static member functions -static_assert(quantity_point, metre, int>::min().relative().number() == std::numeric_limits::lowest()); -static_assert(quantity_point, metre, int>::max().relative().number() == std::numeric_limits::max()); +static_assert(quantity_point, metre, int>::min().relative().number() == + std::numeric_limits::lowest()); +static_assert(quantity_point, metre, int>::max().relative().number() == + std::numeric_limits::max()); static_assert(quantity_point, metre, double>::min().relative().number() == std::numeric_limits::lowest()); static_assert(quantity_point, metre, double>::max().relative().number() == @@ -131,19 +148,23 @@ static_assert(quantity_point, metre, double>::max().r static_assert([](auto v) { auto vv = v++; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(1001_q_m), quantity_point, metre, int>(1000_q_m))); +}(km) == std::pair(quantity_point, metre, int>(1001_q_m), + quantity_point, metre, int>(1000_q_m))); static_assert([](auto v) { auto vv = ++v; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(1001_q_m), quantity_point, metre, int>(1001_q_m))); +}(km) == std::pair(quantity_point, metre, int>(1001_q_m), + quantity_point, metre, int>(1001_q_m))); static_assert([](auto v) { auto vv = v--; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(999_q_m), quantity_point, metre, int>(1000_q_m))); +}(km) == std::pair(quantity_point, metre, int>(999_q_m), + quantity_point, metre, int>(1000_q_m))); static_assert([](auto v) { auto vv = --v; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(999_q_m), quantity_point, metre, int>(999_q_m))); +}(km) == std::pair(quantity_point, metre, int>(999_q_m), + quantity_point, metre, int>(999_q_m))); // compound assignment @@ -153,23 +174,23 @@ static_assert((quantity_point(2_q_m) -= 1_q_m).relative().number() == 1); // non-member arithmetic operators static_assert(compare, metre, int>() + length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare() + quantity_point, metre, double>()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, kilometre, int>() + length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare() + quantity_point, metre, double>()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, metre, double>() - length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, kilometre, double>() - length()), - quantity_point, metre, double>>); -static_assert( - compare, metre, double>() - quantity_point, metre, int>()), - length>); -static_assert( - compare, kilometre, double>() - quantity_point, metre, int>()), - length>); + quantity_point, metre, double>>); +static_assert(compare, metre, double>() - + quantity_point, metre, int>()), + length>); +static_assert(compare, kilometre, double>() - + quantity_point, metre, int>()), + length>); static_assert((1_q_m + km).relative().number() == 1001); static_assert((quantity_point(1_q_m) + 1_q_km).relative().number() == 1001); @@ -177,10 +198,9 @@ static_assert((km - 1_q_m).relative().number() == 999); static_assert((quantity_point(1_q_km) - quantity_point(1_q_m)).number() == 999); template -concept invalid_subtraction = requires(quantity_point, metre, Int> lhs, - quantity_point rhs) { - requires !requires { rhs - lhs; }; -}; +concept invalid_subtraction = + requires(quantity_point, metre, Int> lhs, + quantity_point rhs) { requires !requires { rhs - lhs; }; }; static_assert(invalid_subtraction); // comparators @@ -217,9 +237,9 @@ static_assert(quantity_point(1000_q_m) <= quantity_point(1_q_km)); template concept invalid_comparisons = requires(quantity_point, metre, Int> lhs, quantity_point rhs) { - requires !requires { lhs == rhs; }; - requires !requires { lhs < rhs; }; -}; + requires !requires { lhs == rhs; }; + requires !requires { lhs < rhs; }; + }; static_assert(invalid_comparisons); // alias units @@ -256,25 +276,35 @@ static_assert(std::equality_comparable_with, metre, int>>(quantity_point(2_q_km)).relative().number() == - 2000); -static_assert( - quantity_point_cast, kilometre, int>>(quantity_point(2000_q_m)).relative().number() == 2); -static_assert(quantity_point_cast, metre, int>>(quantity_point(1.23_q_m)).relative().number() == - 1); +static_assert(quantity_point_cast, metre, int>>(quantity_point(2_q_km)) + .relative() + .number() == 2000); +static_assert(quantity_point_cast, kilometre, int>>(quantity_point(2000_q_m)) + .relative() + .number() == 2); +static_assert(quantity_point_cast, metre, int>>(quantity_point(1.23_q_m)) + .relative() + .number() == 1); static_assert(quantity_point_cast>(quantity_point(2_q_km)).relative().number() == 2000); static_assert(quantity_point_cast>(quantity_point(2000_q_m)).relative().number() == 2); static_assert(quantity_point_cast>(quantity_point(1.23_q_m)).relative().number() == 1); static_assert(quantity_point_cast(quantity_point(2_q_km)).relative().number() == 2000); static_assert(quantity_point_cast(quantity_point(2000_q_m)).relative().number() == 2); static_assert(quantity_point_cast(quantity_point(1.23_q_m)).relative().number() == 1); -static_assert(quantity_point_cast(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2); +static_assert( + quantity_point_cast(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2); template -concept invalid_cast = requires(Int i) { - requires !requires { quantity_point_cast, second, Int>>(quantity_point(i * m)); }; - requires !requires { quantity_point_cast, metre, Int>>(quantity_point(i * m)); }; -}; +concept invalid_cast = + requires(Int i) { + requires !requires { + quantity_point_cast, second, Int>>(quantity_point(i * m)); + }; + requires !requires { + quantity_point_cast, metre, Int>>( + quantity_point(i * m)); + }; + }; static_assert(invalid_cast); // time @@ -282,10 +312,7 @@ static_assert(invalid_cast); static_assert(quantity_point{1_q_h} == quantity_point{3600_q_s}); template -concept no_crossdimensional_equality = !requires -{ - quantity_point(1_q_s) == quantity_point(length(1)); -}; +concept no_crossdimensional_equality = !requires { quantity_point(1_q_s) == quantity_point(length(1)); }; static_assert(no_crossdimensional_equality); @@ -297,10 +324,7 @@ static_assert(quantity_point(1_q_km) + 1_q_m == quantity_point(1001_q_m)); static_assert(1_q_km + quantity_point(1_q_m) == quantity_point(1001_q_m)); template -concept dimensional_analysis = requires(T t) -{ - pow<2>(t); -}; +concept dimensional_analysis = requires(T t) { pow<2>(t); }; static_assert(!dimensional_analysis, metre, int>>); diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 9f9b87ae..0f810ccf 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -58,11 +58,11 @@ static_assert(sizeof(length) == sizeof(short)); #if UNITS_COMP_GCC != 10 || UNITS_COMP_GCC_MINOR > 2 template typename Q> concept invalid_types = requires { - requires !requires { typename Q; }; // unit of a different dimension - requires !requires { typename Q>; }; // quantity used as Rep - requires !requires { typename Q; }; // reordered arguments - requires !requires { typename Q; }; // reordered arguments -}; + requires !requires { typename Q; }; // unit of a different dimension + requires !requires { typename Q>; }; // quantity used as Rep + requires !requires { typename Q; }; // reordered arguments + requires !requires { typename Q; }; // reordered arguments + }; static_assert(invalid_types); #endif @@ -128,7 +128,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, float>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, double>); // truncating implicit conversions double -> float allowed +static_assert( + std::constructible_from, double>); // truncating implicit conversions double -> float allowed static_assert(!std::convertible_to>); static_assert(std::constructible_from, int>); @@ -137,7 +138,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, short>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, int>); // truncating implicit conversions int -> short allowed +static_assert( + std::constructible_from, int>); // truncating implicit conversions int -> short allowed static_assert(!std::convertible_to>); // exception, implicit construction from a value allowed for a dimensionless quantity @@ -166,7 +168,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, float>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, double>); // truncating implicit conversions double -> float allowed +static_assert(std::constructible_from, + double>); // truncating implicit conversions double -> float allowed static_assert(!std::convertible_to>); static_assert(std::constructible_from, int>); @@ -175,7 +178,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, short>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, int>); // truncating implicit conversions int -> short allowed +static_assert( + std::constructible_from, int>); // truncating implicit conversions int -> short allowed static_assert(!std::convertible_to>); // floating-point to integral truncating conversion not allowed @@ -185,7 +189,7 @@ static_assert(!std::convertible_to>); static_assert(!std::constructible_from, double>); static_assert(!std::convertible_to>); -static_assert(length().number() == 0); // value initialization +static_assert(length().number() == 0); // value initialization static_assert(length(1).number() == 1); static_assert(length(1.0).number() == 1.0); static_assert(length(1).number() == 1.0); @@ -212,16 +216,18 @@ static_assert(!std::convertible_to, length>); // implicit conversion from another quantity only if non-truncating static_assert(std::constructible_from, length>); // int -> double OK -static_assert(std::convertible_to, length>); // int -> double OK +static_assert(std::convertible_to, length>); // int -> double OK static_assert(!std::constructible_from, length>); // truncating double -> int not allowed -static_assert(!std::convertible_to, length>); // truncating double -> int not allowed +static_assert(!std::convertible_to, length>); // truncating double -> int not allowed static_assert(std::constructible_from, length>); // kilometre -> metre OK -static_assert(std::convertible_to, length>); // kilometre -> metre OK +static_assert(std::convertible_to, length>); // kilometre -> metre OK -static_assert(!std::constructible_from, length>); // truncating metre -> kilometre not allowed -static_assert(!std::convertible_to, length>); // truncating metre -> kilometre not allowed +static_assert(!std::constructible_from, + length>); // truncating metre -> kilometre not allowed +static_assert(!std::convertible_to, + length>); // truncating metre -> kilometre not allowed // converting to double always OK static_assert(std::constructible_from, length>); @@ -249,13 +255,21 @@ struct derived_quantity : quantity constexpr explicit(!std::is_trivial_v) derived_quantity(const R& t) : R(t) {} constexpr explicit(!std::is_trivial_v) derived_quantity(R&& t) : R(std::move(t)) {} - constexpr derived_quantity& operator=(const R& t) { R::operator=(t); return *this; } - constexpr derived_quantity& operator=(R&& t) { R::operator=(std::move(t)); return *this; } + constexpr derived_quantity& operator=(const R& t) + { + R::operator=(t); + return *this; + } + constexpr derived_quantity& operator=(R&& t) + { + R::operator=(std::move(t)); + return *this; + } constexpr operator R&() & noexcept { return *this; } - constexpr operator const R&() const & noexcept { return *this; } + constexpr operator const R&() const& noexcept { return *this; } constexpr operator R&&() && noexcept { return *this; } - constexpr operator const R&&() const && noexcept { return *this; } + constexpr operator const R&&() const&& noexcept { return *this; } }; static_assert(detail::is_quantity, "NTTP type description">>); @@ -290,8 +304,16 @@ static_assert(is_same_v>); // assignment operator //////////////////////// -static_assert([]() { length l1(1), l2(2); return l2 = l1; }().number() == 1); -static_assert([]() { length l1(1), l2(2); return l2 = std::move(l1); }().number() == 1); +static_assert([]() { + length l1(1), l2(2); + return l2 = l1; +}() + .number() == 1); +static_assert([]() { + length l1(1), l2(2); + return l2 = std::move(l1); +}() + .number() == 1); //////////////////// @@ -303,10 +325,22 @@ static_assert((-123_q_m).number() == -123); static_assert((+(-123_q_m)).number() == -123); static_assert((-(-123_q_m)).number() == 123); -static_assert([](auto v) { auto vv = v++; return std::pair(v, vv); }(123_q_m) == std::pair(124_q_m, 123_q_m)); -static_assert([](auto v) { auto vv = ++v; return std::pair(v, vv); }(123_q_m) == std::pair(124_q_m, 124_q_m)); -static_assert([](auto v) { auto vv = v--; return std::pair(v, vv); }(123_q_m) == std::pair(122_q_m, 123_q_m)); -static_assert([](auto v) { auto vv = --v; return std::pair(v, vv); }(123_q_m) == std::pair(122_q_m, 122_q_m)); +static_assert([](auto v) { + auto vv = v++; + return std::pair(v, vv); +}(123_q_m) == std::pair(124_q_m, 123_q_m)); +static_assert([](auto v) { + auto vv = ++v; + return std::pair(v, vv); +}(123_q_m) == std::pair(124_q_m, 124_q_m)); +static_assert([](auto v) { + auto vv = v--; + return std::pair(v, vv); +}(123_q_m) == std::pair(122_q_m, 123_q_m)); +static_assert([](auto v) { + auto vv = --v; + return std::pair(v, vv); +}(123_q_m) == std::pair(122_q_m, 122_q_m)); static_assert(is_same_v); @@ -337,15 +371,32 @@ static_assert((2.5_q_m *= quantity(3)).number() == 7.5); static_assert((7.5_q_m /= quantity(3)).number() == 2.5); static_assert((3500_q_m %= 1_q_km).number() == 500); -static_assert((std::uint8_t(255) * m %= 256).number() == [] { std::uint8_t ui(255); return ui %= 256; }()); -static_assert((std::uint8_t(255) * m %= quantity(256)).number() == [] { std::uint8_t ui(255); return ui %= 256; }()); -// static_assert((std::uint8_t(255) * m %= 256 * m).number() != [] { std::uint8_t ui(255); return ui %= 256; }()); // UB -static_assert((std::uint8_t(255) * m %= 257).number() == [] { std::uint8_t ui(255); return ui %= 257; }()); -static_assert((std::uint8_t(255) * m %= quantity(257)).number() == [] { std::uint8_t ui(255); return ui %= 257; }()); +static_assert((std::uint8_t(255) * m %= 256).number() == [] { + std::uint8_t ui(255); + return ui %= 256; +}()); +static_assert((std::uint8_t(255) * m %= quantity(256)).number() == [] { + std::uint8_t ui(255); + return ui %= 256; +}()); +// static_assert((std::uint8_t(255) * m %= 256 * m).number() != [] { std::uint8_t ui(255); return ui %= 256; }()); // +// UB +static_assert((std::uint8_t(255) * m %= 257).number() == [] { + std::uint8_t ui(255); + return ui %= 257; +}()); +static_assert((std::uint8_t(255) * m %= quantity(257)).number() == [] { + std::uint8_t ui(255); + return ui %= 257; +}()); // TODO: Fix -static_assert((std::uint8_t(255) * m %= 257 * m).number() != [] { std::uint8_t ui(255); return ui %= 257; }()); +static_assert((std::uint8_t(255) * m %= 257 * m).number() != [] { + std::uint8_t ui(255); + return ui %= 257; +}()); -#ifndef UNITS_COMP_MSVC // TODO ICE (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907) +#ifndef UNITS_COMP_MSVC // TODO ICE + // (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907) // next two lines trigger conversions warnings // (warning disabled in CMake for this file) static_assert((22_q_m *= 33.33).number() == 733); @@ -355,43 +406,44 @@ static_assert((22_q_m /= quantity(3.33)).number() == 6); #endif template -concept invalid_compound_assignments = requires() { - // truncating not allowed - requires !requires(length l) { l += 2.5_q_m; }; - requires !requires(length l) { l -= 2.5_q_m; }; - requires !requires(length l) { l += length(2); }; - requires !requires(length l) { l -= length(2); }; - requires !requires(length l) { l %= length(2); }; - requires !requires(length l) { l %= dimensionless(2); }; - requires !requires(length l) { l %= dimensionless(2); }; +concept invalid_compound_assignments = + requires() { + // truncating not allowed + requires !requires(length l) { l += 2.5_q_m; }; + requires !requires(length l) { l -= 2.5_q_m; }; + requires !requires(length l) { l += length(2); }; + requires !requires(length l) { l -= length(2); }; + requires !requires(length l) { l %= length(2); }; + requires !requires(length l) { l %= dimensionless(2); }; + requires !requires(length l) { l %= dimensionless(2); }; - // TODO: accept non-truncating argument - requires !requires(length l) { l *= 1 * (km / m); }; - requires !requires(length l) { l /= 1 * (km / m); }; - requires !requires(length l) { l %= 1 * (km / m); }; + // TODO: accept non-truncating argument + requires !requires(length l) { l *= 1 * (km / m); }; + requires !requires(length l) { l /= 1 * (km / m); }; + requires !requires(length l) { l %= 1 * (km / m); }; - // only quantities can be added or subtracted - requires !requires(length l) { l += 2; }; - requires !requires(length l) { l -= 2; }; + // only quantities can be added or subtracted + requires !requires(length l) { l += 2; }; + requires !requires(length l) { l -= 2; }; - // compound multiply/divide by another quantity not allowed - requires !requires(length l) { l *= 2_q_m; }; - requires !requires(length l) { l /= 2_q_m; }; + // compound multiply/divide by another quantity not allowed + requires !requires(length l) { l *= 2_q_m; }; + requires !requires(length l) { l /= 2_q_m; }; - // modulo operations on a floating point representation not allowed - requires !requires(length l) { l %= 2.; }; - requires !requires(length l) { l %= 2; }; - requires !requires(length l) { l %= 2._q_m; }; - requires !requires(length l) { l %= 2_q_m; }; - requires !requires(length l) { l %= 2._q_m; }; + // modulo operations on a floating point representation not allowed + requires !requires(length l) { l %= 2.; }; + requires !requires(length l) { l %= 2; }; + requires !requires(length l) { l %= 2._q_m; }; + requires !requires(length l) { l %= 2_q_m; }; + requires !requires(length l) { l %= 2._q_m; }; - // no unit constants - requires !requires(length l) { l += m; }; - requires !requires(length l) { l -= m; }; - requires !requires(length l) { l *= m; }; - requires !requires(length l) { l /= m; }; - requires !requires(length l) { l %= m; }; -}; + // no unit constants + requires !requires(length l) { l += m; }; + requires !requires(length l) { l -= m; }; + requires !requires(length l) { l *= m; }; + requires !requires(length l) { l /= m; }; + requires !requires(length l) { l %= m; }; + }; static_assert(invalid_compound_assignments); @@ -401,26 +453,26 @@ static_assert(invalid_compound_assignments); template concept invalid_binary_operations = requires { - // no crossdimensional addition and subtraction - requires !requires { 1_q_s + length(1); }; - requires !requires { 1_q_s - length(1); }; + // no crossdimensional addition and subtraction + requires !requires { 1_q_s + length(1); }; + requires !requires { 1_q_s - length(1); }; - // no floating-point modulo - requires !requires(length a) { a % 2_q_m; }; - requires !requires(length a) { 2_q_m % a; }; - requires !requires(length a) { a % 2; }; - requires !requires(length a, length b) { a % b; }; - requires !requires(length a, length b) { a % b; }; - requires !requires(length a, length b) { b % a; }; + // no floating-point modulo + requires !requires(length a) { a % 2_q_m; }; + requires !requires(length a) { 2_q_m % a; }; + requires !requires(length a) { a % 2; }; + requires !requires(length a, length b) { a % b; }; + requires !requires(length a, length b) { a % b; }; + requires !requires(length a, length b) { b % a; }; - // unit constants - requires !requires { length(1) + m; }; - requires !requires { length(1) - m; }; - requires !requires { length(1) % m; }; - requires !requires { m + length(1); }; - requires !requires { m - length(1); }; - requires !requires { m % length(1); }; -}; + // unit constants + requires !requires { length(1) + m; }; + requires !requires { length(1) - m; }; + requires !requires { length(1) % m; }; + requires !requires { m + length(1); }; + requires !requires { m - length(1); }; + requires !requires { m % length(1); }; + }; static_assert(invalid_binary_operations); // same representation type @@ -443,7 +495,8 @@ static_assert(compare> static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1_q_s), frequency, std::int64_t>>); +static_assert(compare(1) / 1_q_s), + frequency, std::int64_t>>); static_assert(is_same_v); static_assert(is_same_v); @@ -456,9 +509,13 @@ static_assert(is_same_v>); static_assert(is_same_v>); -static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating conversions with concepts? +static_assert( + is_same_v>); // TODO should we address fundamental types implicit + // truncating conversions with concepts? static_assert(is_same_v>); -static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating conversions with concepts? +static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating + // conversions with concepts? static_assert(is_same_v>); static_assert(is_same_v>); static_assert(is_same_v>); @@ -469,7 +526,8 @@ static_assert(compare(1)), static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1._q_s), frequency, long double>>); +static_assert(compare(1) / 1._q_s), + frequency, long double>>); static_assert(compare>); static_assert(compare>); static_assert(compare(1)), length>); @@ -490,7 +548,8 @@ static_assert(compare> static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1_q_s), frequency, long double>>); +static_assert(compare(1) / 1_q_s), + frequency, long double>>); // different units static_assert(is_same_v>); @@ -519,15 +578,21 @@ static_assert(is_same_v>); static_assert(compare, std::int64_t>>); -static_assert(compare, exponent>, scaled_unit, std::int64_t>>); +static_assert( + compare, exponent>, + scaled_unit, std::int64_t>>); static_assert(compare>); static_assert(compare, std::int64_t>>); static_assert(compare>); -static_assert(compare>, scaled_unit, std::int64_t>>); +static_assert( + compare>, + scaled_unit, std::int64_t>>); static_assert(compare, std::int64_t>>); static_assert(compare>); static_assert(compare, std::int64_t>>); -static_assert(compare, exponent>, scaled_unit, std::int64_t>>); +static_assert( + compare, exponent>, + scaled_unit, std::int64_t>>); static_assert((1_q_m + 1_q_m).number() == 2); static_assert((1_q_m + 1_q_km).number() == 1001); @@ -652,9 +717,9 @@ static_assert(quantity{2} / (1 * m) == 2 / 1_q_m); template concept no_crossdimensional_equality = requires { - requires !requires { 1_q_s == length(1); }; - requires !requires { 1_q_s != length(1); }; -}; + requires !requires { 1_q_s == length(1); }; + requires !requires { 1_q_s != length(1); }; + }; static_assert(no_crossdimensional_equality); // same type @@ -688,11 +753,11 @@ static_assert(123 != quantity{321}); template concept no_crossdimensional_ordering = requires { - requires !requires { 1_q_s < length(1); }; - requires !requires { 1_q_s > length(1); }; - requires !requires { 1_q_s <= length(1); }; - requires !requires { 1_q_s >= length(1); }; -}; + requires !requires { 1_q_s < length(1); }; + requires !requires { 1_q_s > length(1); }; + requires !requires { 1_q_s <= length(1); }; + requires !requires { 1_q_s >= length(1); }; + }; static_assert(no_crossdimensional_ordering); // same type @@ -764,9 +829,9 @@ static_assert(!std::equality_comparable_with, double>); template concept invalid_dimensionless_operations = requires { - requires !requires(dimensionless d) { 1 + d; }; - requires !requires(dimensionless d) { d + 1; }; -}; + requires !requires(dimensionless d) { 1 + d; }; + requires !requires(dimensionless d) { d + 1; }; + }; static_assert(invalid_dimensionless_operations); static_assert(compare>); @@ -815,7 +880,9 @@ static_assert(!is_same_v(2_q_dm3)), volume, units::exponent>, scaled_unit, std::int64_t>>); +static_assert(is_same_v, units::exponent>, + scaled_unit, std::int64_t>>); static_assert(is_same_v, std::int64_t>>); #else @@ -846,6 +913,7 @@ static_assert(same(quotient_remainder_theorem(3'000 * m, 400), 3'000 * m)); static_assert(same(quotient_remainder_theorem(3'000 * m, quantity(400)), 3'000 * m)); static_assert(same(quotient_remainder_theorem(3 * km, quantity(400)), 3 * km)); static_assert(same(quotient_remainder_theorem(3 * km, quantity(2)), 3 * km)); -static_assert(same(quotient_remainder_theorem(3 * km, dimensionless, int>(400)), 3 * km)); +static_assert(same(quotient_remainder_theorem(3 * km, dimensionless, int>(400)), + 3 * km)); } // namespace diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index 32de5f10..9eac9963 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -45,7 +45,7 @@ static_assert(-ratio(3, 8) == ratio(-3, 8)); // ratio addition static_assert(ratio(1, 2) + ratio(1, 3) == ratio(5, 6)); -static_assert(ratio(1, 3, 2) + ratio(11, 6) == ratio(211, 6)); // 100/3 + 11/6 +static_assert(ratio(1, 3, 2) + ratio(11, 6) == ratio(211, 6)); // 100/3 + 11/6 // multiply with exponents static_assert(ratio(1, 8, 2) * ratio(2, 1, 4) == ratio(1, 4, 6)); diff --git a/test/unit_test/static/references_test.cpp b/test/unit_test/static/references_test.cpp index 670f0975..ef128436 100644 --- a/test/unit_test/static/references_test.cpp +++ b/test/unit_test/static/references_test.cpp @@ -36,24 +36,24 @@ static_assert(2 * m == 2_q_m); static_assert(2 * s == 2_q_s); template concept invalid_operations = requires { - requires !requires { 2 / s; }; - requires !requires { s / 2; }; - requires !requires { s * 2; }; - requires !requires { s + 2; }; - requires !requires { 2 + s; }; - requires !requires { s + s; }; - requires !requires { s - 2; }; - requires !requires { 2 - s; }; - requires !requires { s - s; }; - requires !requires { s + 1_q_s; }; - requires !requires { s - 1_q_s; }; - requires !requires { s * 1_q_s; }; - requires !requires { s / 1_q_s; }; - requires !requires { 1_q_s + s; }; - requires !requires { 1_q_s - s; }; - requires !requires { 1_q_s * s; }; - requires !requires { 1_q_s / s; }; -}; + requires !requires { 2 / s; }; + requires !requires { s / 2; }; + requires !requires { s * 2; }; + requires !requires { s + 2; }; + requires !requires { 2 + s; }; + requires !requires { s + s; }; + requires !requires { s - 2; }; + requires !requires { 2 - s; }; + requires !requires { s - s; }; + requires !requires { s + 1_q_s; }; + requires !requires { s - 1_q_s; }; + requires !requires { s * 1_q_s; }; + requires !requires { s / 1_q_s; }; + requires !requires { 1_q_s + s; }; + requires !requires { 1_q_s - s; }; + requires !requires { 1_q_s * s; }; + requires !requires { 1_q_s / s; }; + }; static_assert(invalid_operations); static_assert(2_q_m / (1 * s) == 2_q_m_per_s); @@ -77,7 +77,8 @@ static_assert(1. / 4 * m2 == 1._q_m2 / 4); UNITS_DIAGNOSTIC_PUSH UNITS_DIAGNOSTIC_IGNORE_SHADOW -constexpr bool test_hiding() { +constexpr bool test_hiding() +{ Speed auto v0 = 10 * (m / s); signed s = 2; // hides ^ Length auto v = 20 * m / s; diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp index 81a67faa..42e91ad8 100644 --- a/test/unit_test/static/si_cgs_test.cpp +++ b/test/unit_test/static/si_cgs_test.cpp @@ -21,16 +21,16 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep namespace { @@ -40,8 +40,10 @@ static_assert(units::detail::quantity_ratio> == units::rat static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); static_assert(units::detail::quantity_ratio> == units::ratio(1)); static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); -static_assert(units::detail::quantity_ratio> == units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram -static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here +static_assert(units::detail::quantity_ratio> == + units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram +static_assert(units::detail::quantity_ratio> == + units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here static_assert(si::cgs::length(100) == si::length(1)); static_assert(si::cgs::mass(1'000) == si::mass(1)); @@ -68,7 +70,7 @@ static_assert(si::cgs::energy(10'000'000) == 1_q_J); static_assert(si::cgs::power(10'000'000) == 1_q_W); static_assert(si::cgs::pressure(10) == 1_q_Pa); -} +} // namespace si_test namespace cgs_test { @@ -84,7 +86,7 @@ static_assert(10'000'000_q_erg == si::energy(1)); static_assert(10'000'000_q_erg_per_s == si::power(1)); static_assert(10_q_Ba == si::pressure(1)); -} +} // namespace cgs_test namespace both_test { @@ -101,7 +103,7 @@ static_assert(10'000'000_q_erg == 1_q_J); static_assert(10'000'000_q_erg_per_s == 1_q_W); static_assert(10_q_Ba == quantity_cast(1_q_Pa)); -} +} // namespace both_test namespace cgs_test { @@ -125,24 +127,29 @@ static_assert(quantity_cast>(si::length(2) == si::area(4)); // TODO Add support for comparing of an unknown_dimension +// static_assert(200_q_cm * si::length(2) == si::area(4)); // TODO Add support for +// comparing of an unknown_dimension static_assert(quantity_cast(200._q_cm) * si::length(2) == si::area(4)); static_assert(200._q_cm * quantity_cast(si::length(2)) == 40'000_q_cm2); // TODO Add support for quantity_cast on an unknown_dimension? -// static_assert(quantity_cast>(200_q_cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast(200_q_cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast>(200_q_cm * si::length(2)) == 40'000_q_cm2); -// static_assert(quantity_cast(200_q_cm * si::length(2)) == 40'000_q_cm2); +// static_assert(quantity_cast>(200_q_cm * si::length(2)) == +// si::area(4)); static_assert(quantity_cast(200_q_cm * si::length(2)) == +// si::area(4)); static_assert(quantity_cast>(200_q_cm * +// si::length(2)) == 40'000_q_cm2); static_assert(quantity_cast(200_q_cm * +// si::length(2)) == 40'000_q_cm2); // division -// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for comparing of an unknown_dimension +// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for +// comparing of an unknown_dimension -static_assert(si::area(4) / quantity_cast>(200_q_cm) == si::length(2)); -static_assert(quantity_cast>(si::area(4)) / 200._q_cm == 200_q_cm); +static_assert(si::area(4) / quantity_cast>(200_q_cm) == + si::length(2)); +static_assert(quantity_cast>(si::area(4)) / 200._q_cm == + 200_q_cm); -} +} // namespace cgs_test -} +} // namespace diff --git a/test/unit_test/static/si_fps_test.cpp b/test/unit_test/static/si_fps_test.cpp index d9e494d1..a3b0aeb5 100644 --- a/test/unit_test/static/si_fps_test.cpp +++ b/test/unit_test/static/si_fps_test.cpp @@ -41,7 +41,8 @@ static_assert(si::fps::mass(1) == si::mass(0.45359 static_assert(si::fps::time(1) == si::time(1)); static_assert(si::fps::speed(1) == si::speed(0.3048)); static_assert(si::fps::area(1) == si::area(0.09290304)); -static_assert(si::fps::acceleration(1) == si::acceleration(0.3048)); +static_assert(si::fps::acceleration(1) == + si::acceleration(0.3048)); static_assert(si::fps::force(1) > si::force(0.138254) && si::fps::force(1) < si::force(0.138256)); static_assert(si::fps::energy(1) > si::energy(0.042140110093804) && @@ -61,15 +62,14 @@ static_assert(si::fps::time(1) == 1_q_s); static_assert(si::fps::speed(1) == 0.3048_q_m_per_s); static_assert(si::fps::area(1) == 0.09290304_q_m2); static_assert(si::fps::acceleration(1) == 0.3048_q_m_per_s2); -static_assert(si::fps::force(1) > 0.138254_q_N && - si::fps::force(1) < 0.138256_q_N); +static_assert(si::fps::force(1) > 0.138254_q_N && si::fps::force(1) < 0.138256_q_N); static_assert(si::fps::energy(1) > 0.042140110093804_q_J && si::fps::energy(1) < 0.042140110093806_q_J); static_assert(si::fps::power(1) > 0.042140110093804_q_W && si::fps::power(1) < 0.042140110093806_q_W); -static_assert(si::fps::pressure(1) > 1.4881639435_q_Pa && - si::fps::pressure(1) < 1.4881639437_q_Pa); -} +static_assert(si::fps::pressure(1) > 1.4881639435_q_Pa && + si::fps::pressure(1) < 1.4881639437_q_Pa); +} // namespace si_literals namespace fps_literals { @@ -82,15 +82,14 @@ static_assert(1_q_s == si::time(1)); static_assert(1_q_ft_per_s == si::speed(0.3048)); static_assert(1_q_ft2 == si::area(0.09290304)); static_assert(1_q_ft_per_s2 == si::acceleration(0.3048)); -static_assert(1_q_pdl > si::force(0.138254) && - 1_q_pdl < si::force(0.138256)); +static_assert(1_q_pdl > si::force(0.138254) && 1_q_pdl < si::force(0.138256)); static_assert(1_q_ft_pdl > si::energy(0.042140110093804) && 1_q_ft_pdl < si::energy(0.042140110093806)); static_assert(1_q_ft_pdl_per_s > si::power(0.042140110093804) && 1_q_ft_pdl_per_s < si::power(0.042140110093806)); -static_assert(1_q_pdl_per_ft2> si::pressure(1.4881639435) && +static_assert(1_q_pdl_per_ft2 > si::pressure(1.4881639435) && 1_q_pdl_per_ft2 < si::pressure(1.4881639437)); -} +} // namespace fps_literals namespace fps_plus_si_literals { @@ -102,20 +101,16 @@ using namespace units::isq::si::fps::references; // static_assert(1'000_q_g == 1_q_kg); // ambiguous static_assert(1 * ft == 0.3048_q_m); static_assert(1_q_lb == 0.45359237_q_kg); -static_assert(1_q_s == 1_q_s); +static_assert(1_q_s == 1_q_s); static_assert(1_q_ft_per_s == 0.3048_q_m_per_s); static_assert(1_q_ft2 == 0.09290304_q_m2); static_assert(1_q_ft_per_s2 == 0.3048_q_m_per_s2); -static_assert(1_q_pdl > 0.138254_q_N && - 1_q_pdl < 0.138256_q_N); -static_assert(1_q_ft_pdl > 0.042140110093804_q_J && - 1_q_ft_pdl < 0.042140110093806_q_J); -static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W && - 1_q_ft_pdl_per_s < 0.042140110093806_q_W); -static_assert(1_q_pdl_per_ft2> 1.4881639435_q_Pa && - 1_q_pdl_per_ft2 <1.4881639437_q_Pa); +static_assert(1_q_pdl > 0.138254_q_N && 1_q_pdl < 0.138256_q_N); +static_assert(1_q_ft_pdl > 0.042140110093804_q_J && 1_q_ft_pdl < 0.042140110093806_q_J); +static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W && 1_q_ft_pdl_per_s < 0.042140110093806_q_W); +static_assert(1_q_pdl_per_ft2 > 1.4881639435_q_Pa && 1_q_pdl_per_ft2 < 1.4881639437_q_Pa); -} +} // namespace fps_plus_si_literals namespace fps_test { @@ -126,34 +121,49 @@ using namespace units::isq::si::fps::references; static_assert(si::length(1) + 1 * ft == si::length(1.3048)); static_assert(1 * ft + si::length(1) == si::length(1.3048)); -static_assert(quantity_cast>(1. * ft / 0.3048) + si::length(1) == si::length(2)); // 1 m in ft + 1 m -static_assert(si::length(1) + quantity_cast>(1. * ft / 0.3048) == si::length(2)); // 1 m + 1 m in ft -static_assert(1 * ft + quantity_cast>(si::length(0.3048)) == 2 * ft); // 1 ft + 1 ft in m -static_assert(quantity_cast>(si::length(0.3048)) + 1 * ft == 2 * ft); // 1 ft in m + 1 ft +static_assert(quantity_cast>(1. * ft / 0.3048) + si::length(1) == + si::length(2)); // 1 m in ft + 1 m +static_assert(si::length(1) + quantity_cast>(1. * ft / 0.3048) == + si::length(2)); // 1 m + 1 m in ft +static_assert(1 * ft + quantity_cast>(si::length(0.3048)) == + 2 * ft); // 1 ft + 1 ft in m +static_assert(quantity_cast>(si::length(0.3048)) + 1 * ft == + 2 * ft); // 1 ft in m + 1 ft // substraction static_assert(1 * ft - si::length(1) == -si::length(0.6952)); static_assert(si::length(1) - 1 * ft == si::length(0.6952)); -static_assert(quantity_cast>(6. * ft) - si::length(1) > si::length(0.8287) && - quantity_cast>(6. * ft) - si::length(1) < si::length(0.8289)); // 6 ft in m - 1 m = ... m -static_assert(si::length(5) - quantity_cast>(6 * ft) == si::length(3.1712)); // 5 m - 6 ft in m = ... -static_assert(6. * ft - quantity_cast>(si::length(0.3048)) == 5. * ft); // 6 ft - 1 ft in m = 5 ft -static_assert(quantity_cast>(si::length(1.8288)) - 1. * ft == 5. * ft); // 6 ft in m - 1 ft = 5 ft +static_assert(quantity_cast>(6. * ft) - si::length(1) > + si::length(0.8287) && + quantity_cast>(6. * ft) - si::length(1) < + si::length(0.8289)); // 6 ft in m - 1 m = ... m +static_assert(si::length(5) - quantity_cast>(6 * ft) == + si::length(3.1712)); // 5 m - 6 ft in m = ... +static_assert(6. * ft - quantity_cast>(si::length(0.3048)) == + 5. * ft); // 6 ft - 1 ft in m = 5 ft +static_assert(quantity_cast>(si::length(1.8288)) - 1. * ft == + 5. * ft); // 6 ft in m - 1 ft = 5 ft // multiplication -// static_assert(2 * ft * si::length(2) == si::area(1.2192)); // TODO Add support for comparing of an unknown_dimension -static_assert(quantity_cast>(2. * ft) * si::length(2) == si::area(1.2192)); -static_assert(quantity_cast>(2. * ft) * si::length(0.6096) == si::area(0.371612160)); // 2 ft * 2 ft == 4 sq ft +// static_assert(2 * ft * si::length(2) == si::area(1.2192)); // TODO Add support for +// comparing of an unknown_dimension +static_assert(quantity_cast>(2. * ft) * si::length(2) == + si::area(1.2192)); +static_assert(quantity_cast>(2. * ft) * si::length(0.6096) == + si::area(0.371612160)); // 2 ft * 2 ft == 4 sq ft static_assert(2. * ft * quantity_cast>(si::length(0.6096)) == 4._q_ft2); // division -// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for comparing of an unknown_dimension -static_assert(si::area(1.48644864) / quantity_cast>(4 * ft) == si::length(1.2192)); // 16 ft2 / 4 ft = 4 ft -static_assert(quantity_cast>(si::area(1.48644864)) / (4. * ft) == 4. * ft); // 16 ft2 / 4 ft = 4 ft +// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for +// comparing of an unknown_dimension +static_assert(si::area(1.48644864) / quantity_cast>(4 * ft) == + si::length(1.2192)); // 16 ft2 / 4 ft = 4 ft +static_assert(quantity_cast>(si::area(1.48644864)) / (4. * ft) == + 4. * ft); // 16 ft2 / 4 ft = 4 ft -} +} // namespace fps_test -} +} // namespace diff --git a/test/unit_test/static/si_hep_test.cpp b/test/unit_test/static/si_hep_test.cpp index 4e1bfbaa..914ceddd 100644 --- a/test/unit_test/static/si_hep_test.cpp +++ b/test/unit_test/static/si_hep_test.cpp @@ -23,9 +23,9 @@ #include #include #include -#include #include #include +#include namespace { @@ -45,7 +45,8 @@ static_assert(si::momentum(1'000'000) == si::hep::momentum(1e28) == si::area(1)); -//static_assert(si::area(1) == si::area(1e-28)); // numeric rounding issues on some platforms +// static_assert(si::area(1) == si::area(1e-28)); // numeric rounding issues on some +// platforms namespace hep_literal_test { @@ -62,9 +63,10 @@ static_assert(si::hep::momentum(1'000) == 1_q_keV_per_c); static_assert(si::hep::momentum(1'000'000) == 1_q_MeV_per_c); // static_assert(si::area(1e-28L) == 1_q_b); // numeric rounding issues on some platforms -//static_assert(si::hep::area(1e-4L) == 1_q_b); // numeric rounding issues on some platforms +// static_assert(si::hep::area(1e-4L) == 1_q_b); // numeric rounding issues on some +// platforms static_assert(si::area(1e-43) == 1_q_fb); -} +} // namespace hep_literal_test -} +} // namespace diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index bc7e16fb..a69c1f1b 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -334,16 +334,18 @@ static_assert(1_q_J_per_K * 1_q_K == 1_q_s * 1_q_N * 1_q_m_per_s); static_assert(1_q_J_per_mol_K == 1_q_J_per_K / 1_q_mol); static_assert(detail::unit_text() == "J/K"); -static_assert(detail::unit_text() == basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1")); +static_assert(detail::unit_text() == + basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1")); // thermal conductivity static_assert(20_q_W_per_m_K * 10_q_m * 300_q_K == 60'000_q_W); -static_assert(detail::unit_text() == basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1")); +static_assert(detail::unit_text() == + basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1")); // electric field strength -static_assert(100_q_N/20_q_C == 5_q_V_per_m); +static_assert(100_q_N / 20_q_C == 5_q_V_per_m); static_assert(1_q_C * 10_q_V_per_m * 3_q_m == 30_q_J); static_assert(detail::unit_text() == "V/m"); @@ -358,12 +360,13 @@ static_assert(1_q_C_per_m2 == 1_q_C_per_m3 * 1_q_m); static_assert(1_q_V_per_m * 10_q_C_per_m3 * 1_q_m3 == 10_q_N); static_assert(detail::unit_text() == basic_symbol_text("C/m³", "C/m^3")); -static_assert(detail::unit_text() == basic_symbol_text("C/m²", "C/m^2")); +static_assert(detail::unit_text() == + basic_symbol_text("C/m²", "C/m^2")); // permittivity static_assert(1_q_F_per_m == 1_q_F / 1_q_m); -static_assert(1/(1_q_F_per_m) * 1_q_C * 1_q_C / 1_q_m2 == 1_q_N); +static_assert(1 / (1_q_F_per_m) * 1_q_C * 1_q_C / 1_q_m2 == 1_q_N); static_assert(1_q_C_per_m3 / 1_q_F_per_m * 1_q_m == 1_q_V_per_m); static_assert(detail::unit_text() == "F/m"); diff --git a/test/unit_test/static/symbol_text_test.cpp b/test/unit_test/static/symbol_text_test.cpp index c1e4ffd5..03173810 100644 --- a/test/unit_test/static/symbol_text_test.cpp +++ b/test/unit_test/static/symbol_text_test.cpp @@ -92,4 +92,4 @@ static_assert(sym6 + basic_fixed_string("f") == basic_symbol_text("bcf", "def")) static_assert("a" + sym6 == basic_symbol_text("abc", "ade")); static_assert(sym6 + "f" == basic_symbol_text("bcf", "def")); -} +} // namespace diff --git a/test/unit_test/static/type_list_test.cpp b/test/unit_test/static/type_list_test.cpp index d4ea9dcd..186e0ba0 100644 --- a/test/unit_test/static/type_list_test.cpp +++ b/test/unit_test/static/type_list_test.cpp @@ -50,8 +50,10 @@ static_assert(is_same_v, type_list<>, type_list<>>, t static_assert(is_same_v, type_list<>, type_list<>>, type_list>); static_assert(is_same_v, type_list, type_list<>>, type_list>); static_assert(is_same_v, type_list<>, type_list>, type_list>); -static_assert(is_same_v, type_list, type_list>, type_list>); -static_assert(is_same_v, type_list, type_list>, type_list>); +static_assert( + is_same_v, type_list, type_list>, type_list>); +static_assert(is_same_v, type_list, type_list>, + type_list>); // type_list_split @@ -87,10 +89,9 @@ static_assert(is_same_v>::second_list, static_assert(is_same_v>::first_list, type_list>); static_assert(is_same_v>::second_list, type_list>); +static_assert(is_same_v>::first_list, type_list>); static_assert( - is_same_v>::first_list, type_list>); -static_assert( - is_same_v>::second_list, type_list>); + is_same_v>::second_list, type_list>); // type_list_merge_sorted struct u0 : named_unit {}; @@ -98,10 +99,12 @@ struct d0 : base_dimension<"d0", u0> {}; struct u1 : named_unit {}; struct d1 : base_dimension<"d1", u1> {}; -static_assert(is_same_v>, type_list>, exponent_less>, - type_list, units::exponent>>); -static_assert(is_same_v>, type_list>, exponent_less>, - type_list, units::exponent>>); +static_assert( + is_same_v>, type_list>, exponent_less>, + type_list, units::exponent>>); +static_assert( + is_same_v>, type_list>, exponent_less>, + type_list, units::exponent>>); // type_list_sort @@ -109,9 +112,9 @@ template using exp_sort = type_list_sort; static_assert(is_same_v>>, exponent_list>>); -static_assert( - is_same_v, units::exponent>>, exponent_list, units::exponent>>); -static_assert( - is_same_v, units::exponent>>, exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>>, + exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>>, + exponent_list, units::exponent>>); } // namespace diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index ec657dad..4856b09a 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -47,11 +47,14 @@ struct dim_time : base_dimension<"time", second> {}; struct kelvin : named_unit {}; #if !UNITS_COMP_MSVC -static_assert([](P) { return !requires { typename prefixed_unit; }; }(si::kilo{})); // no prefix allowed +static_assert([](P) { + return !requires { typename prefixed_unit; }; +}(si::kilo{})); // no prefix allowed #endif struct metre_per_second : unit {}; -struct dim_speed : derived_dimension, units::exponent> {}; +struct dim_speed : + derived_dimension, units::exponent> {}; struct kilometre_per_hour : derived_unit {}; static_assert(equivalent); @@ -63,7 +66,9 @@ static_assert(compare>, f static_assert(compare>, kilometre_per_hour>); #if !UNITS_COMP_MSVC -static_assert([]() { return !requires { typename scaled_unit; }; }.template operator()()); // negative unit ratio +static_assert([]() { + return !requires { typename scaled_unit; }; +}.template operator()()); // negative unit ratio #endif static_assert(centimetre::symbol == "cm");