diff --git a/README.md b/README.md index 801ac8a3..0311ffef 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ the below example for a quick preview of basic library features: #include #include -using namespace units; +using namespace units::physical; constexpr Velocity auto avg_speed(Length auto d, Time auto t) { @@ -63,7 +63,7 @@ constexpr Velocity auto avg_speed(Length auto d, Time auto t) int main() { - using namespace si::literals; + using namespace units::physical::si::literals; Velocity auto v1 = avg_speed(220q_km, 2q_h); Velocity auto v2 = avg_speed(si::length(140), si::time(2)); Velocity auto v3 = quantity_cast(v2); diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 20816cb1..da77b31f 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -148,7 +148,7 @@ in the design documentation. Coming back to units, here are a few examples of unit definitions: ```cpp -namespace units::si { +namespace units::physical::si { // prefixes struct prefix : prefix_family {}; @@ -170,7 +170,7 @@ struct kilometre_per_hour : deduced_unit, si::metre> {}; @@ -224,7 +224,7 @@ These identifiers provide total ordering of exponents of base dimensions in a de The SI physical units system defines 7 base dimensions: ```cpp -namespace units::si { +namespace units::physical::si { struct dim_length : base_dimension<"L", metre> {}; struct dim_mass : base_dimension<"M", kilogram> {}; @@ -244,7 +244,7 @@ base unit is needed for the text output of unnamed derived units. Second, there one system of physical units. For example CGS definitions look as follows: ```cpp -namespace units::cgs { +namespace units::physical::cgs { using si::centimetre; using si::gram; @@ -354,7 +354,7 @@ directly define a barye in terms of pascal or vice versa. Below are a few examples of derived dimension definitions: ```cpp -namespace units::si { +namespace units::physical::si { struct dim_velocity : derived_dimension, exp> {}; @@ -448,8 +448,8 @@ Beside adding new elements a few other changes where applied compared to the `st To simplify writing efficient generic code quantities of each dimension have associated: 1. Concept (i.e. `units::Length`) that matches a length dimension of any physical systems. -2. Per-system quantity alias (i.e. `units::si::length` for - `units::quantity`). +2. Per-system quantity alias (i.e. `units::physical::si::length` for + `units::quantity`). Also, to help instantiate quantities with compile-time known values every unit in the library has an associated UDL. For example: @@ -603,9 +603,9 @@ user. If we will get a compilation error message containing `dim_capacitance` in the compiler will print the following type instead of the alias: ```text -units::detail::derived_dimension_base, -units::exp, units::exp, -units::exp > +units::detail::derived_dimension_base, +units::exp, units::exp, +units::exp > ``` You can notice that even this long syntax was carefully selected to provide quite good user @@ -760,8 +760,8 @@ struct unknown_dimension : derived_dimension, with this the error log or a debugger breakpoint involving a `temp1` type will include: ```text -units::quantity, -units::exp >, units::unknown_coherent_unit, long int> +units::quantity, +units::exp >, units::unknown_coherent_unit, long int> ``` diff --git a/docs/design.rst b/docs/design.rst index e13e58e8..d3dc9231 100644 --- a/docs/design.rst +++ b/docs/design.rst @@ -6,6 +6,7 @@ Design Deep Dive For brevity all the code examples in this chapter assume:: using namespace units; + using namespace units::physical; .. toctree:: :maxdepth: 2 diff --git a/docs/framework.rst b/docs/framework.rst index bb3e834a..e33e8d48 100644 --- a/docs/framework.rst +++ b/docs/framework.rst @@ -6,6 +6,7 @@ Framework Basics For brevity all the code examples in this chapter assume:: using namespace units; + using namespace units::physical; .. toctree:: :maxdepth: 2 diff --git a/docs/framework/quantities.rst b/docs/framework/quantities.rst index b83d84d4..00f8c8ea 100644 --- a/docs/framework/quantities.rst +++ b/docs/framework/quantities.rst @@ -47,7 +47,7 @@ values the library provides :abbr:`UDL (User Defined Literal)` s for each :term:`unit` of every :term:`dimension`. Thanks to them the same code can be as simple as:: - using namespace si::literals; + using namespace units::physical::si::literals; constexpr auto d1 = 123q_km; // si::length constexpr auto d2 = 123.q_km; // si::length @@ -66,7 +66,7 @@ In case the user does not care about the specific unit and representation but requires quantity of a concrete dimension than dimension-specific concepts can be used:: - using namespace si::literals; + using namespace units::physical::si::literals; constexpr Length auto d = 123q_km; // si::length .. note:: @@ -80,8 +80,8 @@ assume that the user wants to implement an ``avg_speed`` function that will be calculating the average speed based on provided distance and duration quantities. The usage of such a function can look as follows:: - using namespace si::literals; - using namespace international::literals; + using namespace units::physical::si::literals; + using namespace units::physical::international::literals; constexpr Velocity auto v1 = avg_speed(220q_km, 2q_h); constexpr Velocity auto v2 = avg_speed(140q_mi, 2q_h); diff --git a/docs/framework/text_output.rst b/docs/framework/text_output.rst index d6c17f06..2a10e41a 100644 --- a/docs/framework/text_output.rst +++ b/docs/framework/text_output.rst @@ -12,8 +12,8 @@ Output Streams The easiest way to print a quantity is to provide its object to the output stream:: - using namespace si::literals; - using namespace international::literals; + using namespace units::physical::si::literals; + using namespace units::physical::international::literals; constexpr Velocity auto v1 = avg_speed(220.q_km, 2q_h); constexpr Velocity auto v2 = avg_speed(140.q_mi, 2q_h); std::cout << v1 << '\n'; // 110 km/h diff --git a/docs/framework/units.rst b/docs/framework/units.rst index 225facd5..47d4a319 100644 --- a/docs/framework/units.rst +++ b/docs/framework/units.rst @@ -161,8 +161,8 @@ of ``N/m``): :emphasize-lines: 2 struct dim_surface_tension : derived_dimension, - exp> {}; // N/m + exp, + exp> {}; // N/m If we defined the above in terms of base units we would end up with a ``kg/s²`` derived unit symbol. @@ -361,7 +361,7 @@ and user should not instantiate it by him/her-self. However the user can sometim observe this type in case an unit/dimension conversion expression will end up with an unknown/undefined unit type like in the below example:: - using namespace si::literals; + using namespace units::physical::si::literals; Length auto l = 100q_km_per_h * 10q_s; diff --git a/docs/quick_start.rst b/docs/quick_start.rst index e41e8853..fb59fde2 100644 --- a/docs/quick_start.rst +++ b/docs/quick_start.rst @@ -32,7 +32,7 @@ of basic library features:: #include #include - using namespace units; + using namespace units::physical; constexpr Velocity auto avg_speed(Length auto d, Time auto t) { @@ -41,7 +41,7 @@ of basic library features:: int main() { - using namespace si::literals; + using namespace units::physical::si::literals; Velocity auto v1 = avg_speed(220q_km, 2q_h); Velocity auto v2 = avg_speed(si::length(140), si::time(2)); Velocity auto v3 = quantity_cast(v2); diff --git a/docs/reference/systems.rst b/docs/reference/systems.rst index 77ffb0cc..09e62e0f 100644 --- a/docs/reference/systems.rst +++ b/docs/reference/systems.rst @@ -8,7 +8,7 @@ Systems SI -- -.. doxygennamespace:: units::si +.. doxygennamespace:: units::physical::si :members: :undoc-members: :outline: diff --git a/docs/use_cases.rst b/docs/use_cases.rst index 89816b92..b3be890d 100644 --- a/docs/use_cases.rst +++ b/docs/use_cases.rst @@ -6,6 +6,7 @@ Use Cases For brevity all the code examples in this chapter assume:: using namespace units; + using namespace units::physical; .. toctree:: :maxdepth: 2 diff --git a/docs/use_cases/legacy_interfaces.rst b/docs/use_cases/legacy_interfaces.rst index 0edd399c..e689a373 100644 --- a/docs/use_cases/legacy_interfaces.rst +++ b/docs/use_cases/legacy_interfaces.rst @@ -21,7 +21,7 @@ pass it to the library's output: #include "legacy.h" #include - using namespace units; + using namespace units::physical; constexpr Velocity auto avg_speed(Length auto d, Time auto t) { diff --git a/example/alternative_namespaces/acceleration.h b/example/alternative_namespaces/acceleration.h index 3f104517..404a3187 100644 --- a/example/alternative_namespaces/acceleration.h +++ b/example/alternative_namespaces/acceleration.h @@ -9,7 +9,7 @@ namespace experimental{ namespace acceleration { template -using m_per_s2 = units::si::acceleration; +using m_per_s2 = units::physical::si::acceleration; template constexpr m_per_s2 g{static_cast(9.80665)}; diff --git a/example/alternative_namespaces/area.h b/example/alternative_namespaces/area.h index 610542e7..fb1a9ab9 100644 --- a/example/alternative_namespaces/area.h +++ b/example/alternative_namespaces/area.h @@ -6,9 +6,9 @@ namespace area { template -using m2 = units::si::area; +using m2 = units::physical::si::area; template -using fm2 = units::si::area; +using fm2 = units::physical::si::area; } // namespace area diff --git a/example/alternative_namespaces/box_example.cpp b/example/alternative_namespaces/box_example.cpp index d18b25bd..d22c9bc6 100644 --- a/example/alternative_namespaces/box_example.cpp +++ b/example/alternative_namespaces/box_example.cpp @@ -52,7 +52,7 @@ struct Box { #include -using namespace units::si::literals; +using namespace units::physical::si::literals; int main() { diff --git a/example/alternative_namespaces/capacitor_time_curve.cpp b/example/alternative_namespaces/capacitor_time_curve.cpp index 9577a98f..8ff58195 100644 --- a/example/alternative_namespaces/capacitor_time_curve.cpp +++ b/example/alternative_namespaces/capacitor_time_curve.cpp @@ -28,7 +28,7 @@ #include using namespace units::experimental; -using namespace units::si::literals; +using namespace units::physical::si::literals; int main() { diff --git a/example/alternative_namespaces/clcpp_response.cpp b/example/alternative_namespaces/clcpp_response.cpp index 567b3100..6d295ed6 100644 --- a/example/alternative_namespaces/clcpp_response.cpp +++ b/example/alternative_namespaces/clcpp_response.cpp @@ -24,8 +24,8 @@ #include "./area.h" #include "./units_str.h" -using namespace units::si::literals; -using namespace units::international; +using namespace units::physical::si::literals; +using namespace units::physical::international; using namespace units::experimental; void simple_quantities() diff --git a/example/alternative_namespaces/conversion_factor.cpp b/example/alternative_namespaces/conversion_factor.cpp index 900d0552..8e11a66e 100644 --- a/example/alternative_namespaces/conversion_factor.cpp +++ b/example/alternative_namespaces/conversion_factor.cpp @@ -40,7 +40,7 @@ inline constexpr std::common_type_t } // namespace -using namespace units::si::literals; +using namespace units::physical::si::literals; using namespace units::experimental; int main() diff --git a/example/alternative_namespaces/density.h b/example/alternative_namespaces/density.h index 5a9dc60b..870da078 100644 --- a/example/alternative_namespaces/density.h +++ b/example/alternative_namespaces/density.h @@ -10,7 +10,7 @@ namespace experimental{ namespace density { template -using kg_per_m3 = units::si::density; +using kg_per_m3 = units::physical::si::density; } diff --git a/example/alternative_namespaces/force.h b/example/alternative_namespaces/force.h index a2cefd4d..ad0945e5 100644 --- a/example/alternative_namespaces/force.h +++ b/example/alternative_namespaces/force.h @@ -9,7 +9,7 @@ namespace experimental{ namespace force { template -using N = units::si::force; +using N = units::physical::si::force; } diff --git a/example/alternative_namespaces/length.h b/example/alternative_namespaces/length.h index 7410a0be..8d0f94f9 100644 --- a/example/alternative_namespaces/length.h +++ b/example/alternative_namespaces/length.h @@ -15,70 +15,70 @@ namespace experimental{ namespace length { template -using m = units::si::length; +using m = units::physical::si::length; template -using mm = units::si::length; +using mm = units::physical::si::length; template -using fm = units::si::length; +using fm = units::physical::si::length; template -using km = units::si::length; +using km = units::physical::si::length; template -using AU = units::si::length; +using AU = units::physical::si::length; template -using in = units::si::length; +using in = units::physical::si::length; template -using angstrom = units::si::length; +using angstrom = units::physical::si::length; template -using ch = units::si::length; +using ch = units::physical::si::length; template -using fathom = units::si::length; +using fathom = units::physical::si::length; template -using fathom_us = units::si::length; +using fathom_us = units::physical::si::length; template -using ft = units::si::length; +using ft = units::physical::si::length; template -using ft_us = units::si::length; +using ft_us = units::physical::si::length; template -using ly = units::si::length; +using ly = units::physical::si::length; template -using mi = units::si::length; +using mi = units::physical::si::length; template -using mi_naut = units::si::length; +using mi_naut = units::physical::si::length; template -using pc = units::si::length; +using pc = units::physical::si::length; template -using pica_comp = units::si::length; +using pica_comp = units::physical::si::length; template -using pica_prn = units::si::length; +using pica_prn = units::physical::si::length; template -using point_comp = units::si::length; +using point_comp = units::physical::si::length; template -using point_prn = units::si::length; +using point_prn = units::physical::si::length; template -using rd = units::si::length; +using rd = units::physical::si::length; template -using yd = units::si::length; +using yd = units::physical::si::length; } // namespace length diff --git a/example/alternative_namespaces/mass.h b/example/alternative_namespaces/mass.h index 39c93c74..57816bc7 100644 --- a/example/alternative_namespaces/mass.h +++ b/example/alternative_namespaces/mass.h @@ -10,7 +10,7 @@ namespace experimental{ namespace mass { template -using kg = units::si::mass; +using kg = units::physical::si::mass; } diff --git a/example/alternative_namespaces/time.h b/example/alternative_namespaces/time.h index a72418aa..f1d6650f 100644 --- a/example/alternative_namespaces/time.h +++ b/example/alternative_namespaces/time.h @@ -7,15 +7,15 @@ namespace q_time { template -using s = units::si::time; +using s = units::physical::si::time; template -using ms = units::si::time; +using ms = units::physical::si::time; template -using min = units::si::time; +using min = units::physical::si::time; template -using h = units::si::time; +using h = units::physical::si::time; } // namespace time diff --git a/example/alternative_namespaces/timer.cpp b/example/alternative_namespaces/timer.cpp index c2a90c1f..3f173f4b 100644 --- a/example/alternative_namespaces/timer.cpp +++ b/example/alternative_namespaces/timer.cpp @@ -7,7 +7,7 @@ */ using namespace units::experimental; -using namespace units::si::literals; +using namespace units::physical::si::literals; int main() { diff --git a/example/alternative_namespaces/voltage.h b/example/alternative_namespaces/voltage.h index a0807e50..258f597c 100644 --- a/example/alternative_namespaces/voltage.h +++ b/example/alternative_namespaces/voltage.h @@ -10,19 +10,19 @@ namespace experimental{ namespace voltage { template -using V = units::si::voltage; +using V = units::physical::si::voltage; template -using mV = units::si::voltage; +using mV = units::physical::si::voltage; template -using uV = units::si::voltage; +using uV = units::physical::si::voltage; template -using nV = units::si::voltage; +using nV = units::physical::si::voltage; template -using pV = units::si::voltage; +using pV = units::physical::si::voltage; } // namespace voltage diff --git a/example/alternative_namespaces/volume.h b/example/alternative_namespaces/volume.h index a6fa2c39..ff10fcfc 100644 --- a/example/alternative_namespaces/volume.h +++ b/example/alternative_namespaces/volume.h @@ -10,7 +10,7 @@ namespace experimental{ namespace volume { template -using m3 = units::si::volume; +using m3 = units::physical::si::volume; } diff --git a/example/avg_speed.cpp b/example/avg_speed.cpp index e66c1c5f..7113dfc4 100644 --- a/example/avg_speed.cpp +++ b/example/avg_speed.cpp @@ -27,47 +27,47 @@ namespace { -constexpr units::si::velocity -fixed_int_si_avg_speed(units::si::length d, - units::si::time t) +using namespace units::physical; + +constexpr si::velocity +fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr units::si::velocity -fixed_double_si_avg_speed(units::si::length d, - units::si::time t) +constexpr si::velocity +fixed_double_si_avg_speed(si::length d, + si::time t) { return d / t; } template -constexpr units::Velocity AUTO si_avg_speed(units::si::length d, - units::si::time t) +constexpr Velocity AUTO si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO t) +constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) { return d / t; } -template +template void print_result(D distance, T duration, V velocity) { - const auto result_in_kmph = units::quantity_cast>(velocity); + const auto result_in_kmph = units::quantity_cast>(velocity); std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph << ".\n"; } void example() { - using namespace units; - // SI (int) { - using namespace units::si::literals; + using namespace units::physical::si::literals; constexpr Length AUTO distance = 220q_km; // constructed from a UDL constexpr si::time duration(2); // constructed from a value @@ -81,7 +81,7 @@ void example() // SI (double) { - using namespace units::si::literals; + using namespace units::physical::si::literals; constexpr Length AUTO distance = 220.q_km; // constructed from a UDL constexpr si::time duration(2); // constructed from a value @@ -97,7 +97,7 @@ void example() // Customary Units (int) { - using namespace units::international::literals; + using namespace units::physical::international::literals; constexpr Length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value @@ -113,7 +113,7 @@ void example() // Customary Units (double) { - using namespace units::international::literals; + using namespace units::physical::international::literals; constexpr Length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value @@ -131,7 +131,7 @@ void example() // CGS (int) { - using namespace units::cgs::literals; + using namespace units::physical::cgs::literals; constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL constexpr cgs::time duration(2); // constructed from a value @@ -150,7 +150,7 @@ void example() // CGS (double) { - using namespace units::cgs::literals; + using namespace units::physical::cgs::literals; constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL constexpr cgs::time duration(2); // constructed from a value diff --git a/example/box_example.cpp b/example/box_example.cpp index 1bc7a5ba..2329a287 100644 --- a/example/box_example.cpp +++ b/example/box_example.cpp @@ -11,8 +11,8 @@ namespace { -using namespace units; -using namespace units::si::literals; +using namespace units::physical; +using namespace units::physical::si::literals; using m = si::metre; using kg = si::kilogram; diff --git a/example/capacitor_time_curve.cpp b/example/capacitor_time_curve.cpp index 4281ff0f..04186e78 100644 --- a/example/capacitor_time_curve.cpp +++ b/example/capacitor_time_curve.cpp @@ -29,8 +29,8 @@ int main() { - using namespace units; - using namespace units::si; + using namespace units::physical; + using namespace units::physical::si; std::cout << "mp-units capacitor time curve example...\n"; std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); diff --git a/example/clcpp_response.cpp b/example/clcpp_response.cpp index d5951497..c117ed25 100644 --- a/example/clcpp_response.cpp +++ b/example/clcpp_response.cpp @@ -33,11 +33,11 @@ using namespace units; void simple_quantities() { - using namespace units::si; - using namespace units::international; + using namespace units::physical::si; + using namespace units::physical::international; using distance = length; - using duration = si::time; + using duration = physical::si::time; constexpr distance km = 1.0q_km; constexpr distance miles = 1.0q_mi; @@ -57,8 +57,9 @@ void simple_quantities() void quantities_with_typed_units() { - using namespace units::si; - using namespace units::international; + using namespace units::physical; + using namespace units::physical::si; + using namespace units::physical::international; constexpr length km = 1.0q_km; constexpr length miles = 1.0q_mi; @@ -104,7 +105,7 @@ void quantities_with_typed_units() void calcs_comparison() { - using namespace units::si; + using namespace units::physical::si; std::cout << "\nA distinct unit for each type is efficient and accurate\n" "when adding two values of the same very big\n" diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 82e71e30..3f9ed02d 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -41,7 +41,7 @@ inline constexpr std::common_type_t int main() { - using namespace units::si; + using namespace units::physical::si; std::cout << "conversion factor in mp-units...\n\n"; diff --git a/example/hello_units.cpp b/example/hello_units.cpp index dc21299a..51ba2ff3 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -25,7 +25,7 @@ #include #include -using namespace units; +using namespace units::physical; constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) { @@ -34,7 +34,7 @@ constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) int main() { - using namespace si::literals; + using namespace units::physical::si::literals; Velocity AUTO v1 = avg_speed(220q_km, 2q_h); Velocity AUTO v2 = avg_speed(si::length(140), si::time(2)); Velocity AUTO v3 = quantity_cast(v2); diff --git a/example/kalman_filter-alpha_beta_filter_example2.cpp b/example/kalman_filter-alpha_beta_filter_example2.cpp index e6b777ab..f2c6b893 100644 --- a/example/kalman_filter-alpha_beta_filter_example2.cpp +++ b/example/kalman_filter-alpha_beta_filter_example2.cpp @@ -20,7 +20,7 @@ struct state_variable { Q predicted_next_state; }; -using namespace units::si; +using namespace units::physical::si; constexpr auto radar_transmit_interval = 5.0q_s; constexpr double kalman_range_gain = 0.2; diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 76fdf2c8..079f6e7c 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -55,8 +55,8 @@ std::ostream& operator<<(std::ostream& os, const std::experimental::math::matrix using namespace std::experimental::math; -using namespace units; -using namespace si::literals; +using namespace units::physical; +using namespace units::physical::si::literals; template using vector = fs_vector; @@ -201,10 +201,10 @@ void matrix_of_quantity_tests() matrix_of_quantity_divide_by_scalar(); } -template +template using length_v = si::length>; -template +template using force_v = si::force>; void quantity_of_vector_add() diff --git a/example/measurement.cpp b/example/measurement.cpp index 8ca3d03f..07db5f86 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -157,7 +157,7 @@ namespace { void example() { - using namespace units; + using namespace units::physical; const auto a = si::acceleration>(measurement(9.8, 0.1)); const auto t = si::time>(measurement(1.2, 0.1)); diff --git a/example/total_energy.cpp b/example/total_energy.cpp index 79d59e52..eab1dd0b 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -30,7 +30,7 @@ namespace { -using namespace units; +using namespace units::physical; Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Velocity AUTO c) { @@ -39,7 +39,7 @@ Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Velocity AUTO c) void si_example() { - using namespace si; + using namespace units::physical::si; using GeV = gigaelectronvolt; constexpr Velocity AUTO c = si2019::speed_of_light<>; @@ -70,7 +70,7 @@ void si_example() void natural_example() { - using namespace natural; + using namespace units::physical::natural; using GeV = gigaelectronvolt; constexpr Velocity AUTO c = speed_of_light<>; diff --git a/example/unknown_dimension.cpp b/example/unknown_dimension.cpp index 3af27ac9..6b213871 100644 --- a/example/unknown_dimension.cpp +++ b/example/unknown_dimension.cpp @@ -25,23 +25,24 @@ namespace { -template -constexpr units::Velocity AUTO avg_speed(D d, T t) +template +constexpr units::physical::Velocity AUTO avg_speed(D d, T t) { return d / t; } void example() { - using namespace units::si::literals; + using namespace units::physical; + using namespace units::physical::si::literals; - units::Length AUTO d1 = 123q_m; - units::Time AUTO t1 = 10q_s; - units::Velocity AUTO v1 = avg_speed(d1, t1); + Length AUTO d1 = 123q_m; + Time AUTO t1 = 10q_s; + Velocity AUTO v1 = avg_speed(d1, t1); auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - units::Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again - units::Length AUTO d2 = v2 * 60q_s; + Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again + Length AUTO d2 = v2 * 60q_s; std::cout << "d1 = " << d1 << '\n'; std::cout << "t1 = " << t1 << '\n'; diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index e894c59d..fa2068af 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -30,13 +30,13 @@ namespace units::data { struct bit_per_second : unit {}; -struct dim_bitrate : derived_dimension, exp> {}; +struct dim_bitrate : derived_dimension, exp> {}; -struct kibibit_per_second : deduced_unit {}; -struct mebibit_per_second : deduced_unit {}; -struct gibibit_per_second : deduced_unit {}; -struct tebibit_per_second : deduced_unit {}; -struct pebibit_per_second : deduced_unit {}; +struct kibibit_per_second : deduced_unit {}; +struct mebibit_per_second : deduced_unit {}; +struct gibibit_per_second : deduced_unit {}; +struct tebibit_per_second : deduced_unit {}; +struct pebibit_per_second : deduced_unit {}; template concept Bitrate = QuantityOf; diff --git a/src/include/units/data/prefixes.h b/src/include/units/data/prefixes.h index 4e6e683a..241534bc 100644 --- a/src/include/units/data/prefixes.h +++ b/src/include/units/data/prefixes.h @@ -35,4 +35,4 @@ struct tebi : units::prefix struct pebi : units::prefix> {}; struct exbi : units::prefix> {}; -} // namespace units::si +} // namespace units::data diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index 38375002..232310c1 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -26,7 +26,7 @@ #include #include -namespace units::cgs { +namespace units::physical::cgs { struct gal : named_unit {}; struct dim_acceleration : physical::dim_acceleration {}; @@ -42,4 +42,4 @@ constexpr auto operator"" q_Gal(long double l) { return acceleration #include -namespace units::cgs { +namespace units::physical::cgs { using si::square_centimetre; @@ -44,4 +44,4 @@ constexpr auto operator"" q_cm2(long double l) { return area #include -namespace units::cgs { +namespace units::physical::cgs { struct erg : named_unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_erg(long double l) { return energy } // namespace literals -} // namespace units::cgs +} // namespace units::physical::cgs diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index 19644b16..ec3e2d7e 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -28,7 +28,7 @@ #include #include -namespace units::cgs { +namespace units::physical::cgs { struct dyne : named_unit {}; @@ -45,4 +45,4 @@ constexpr auto operator"" q_dyn(long double l) { return force } // namespace literals -} // namespace units::cgs +} // namespace units::physical::cgs diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index 2584cfe4..c5d82468 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -26,7 +26,7 @@ #include #include -namespace units::cgs { +namespace units::physical::cgs { using si::centimetre; @@ -43,4 +43,4 @@ constexpr auto operator"" q_cm(long double l) { return length #include -namespace units::cgs { +namespace units::physical::cgs { using si::gram; @@ -43,4 +43,4 @@ constexpr auto operator"" q_g(long double l) { return mass(l) } -} // namespace units::cgs +} // namespace units::physical::cgs diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index 06981b01..6a1c9c2e 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -27,7 +27,7 @@ #include #include -namespace units::cgs { +namespace units::physical::cgs { struct erg_per_second : unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_erg_per_s(long double l) { return power #include -namespace units::cgs { +namespace units::physical::cgs { struct barye : named_unit {}; @@ -45,4 +45,4 @@ constexpr auto operator"" q_Ba(long double l) { return pressure #include -namespace units::cgs { +namespace units::physical::cgs { using si::second; @@ -39,4 +39,4 @@ using si::literals::operator"" q_s; } -} // namespace units::cgs +} // namespace units::physical::cgs diff --git a/src/include/units/physical/cgs/velocity.h b/src/include/units/physical/cgs/velocity.h index 8a96f070..33387715 100644 --- a/src/include/units/physical/cgs/velocity.h +++ b/src/include/units/physical/cgs/velocity.h @@ -27,7 +27,7 @@ #include #include -namespace units::cgs { +namespace units::physical::cgs { struct centimetre_per_second : unit {}; struct dim_velocity : physical::dim_velocity {}; @@ -43,4 +43,4 @@ constexpr auto operator"" q_cm_per_s(long double l) { return velocity #include -namespace units { - -namespace physical { +namespace units::physical { template typename DimTemplate> concept DimensionOf = Dimension && is_derived_from_instantiation; @@ -178,140 +176,138 @@ struct dim_permeability : derived_dimension, exp> {}; template E, DimensionOf M> struct dim_molar_energy : derived_dimension, exp> {}; -} // namespace physical +template +concept Length = QuantityOf; template -concept Length = physical::QuantityOf; +concept Mass = QuantityOf; template -concept Mass = physical::QuantityOf; +concept Time = QuantityOf; template -concept Time = physical::QuantityOf; +concept Current = QuantityOf; template -concept Current = physical::QuantityOf; +concept Temperature = QuantityOf; template -concept Temperature = physical::QuantityOf; +concept Substance = QuantityOf; template -concept Substance = physical::QuantityOf; +concept LuminousIntensity = QuantityOf; template -concept LuminousIntensity = physical::QuantityOf; +concept Frequency = QuantityOf; template -concept Frequency = physical::QuantityOf; +concept Area = QuantityOf; template -concept Area = physical::QuantityOf; +concept Volume = QuantityOf; template -concept Volume = physical::QuantityOf; +concept Velocity = QuantityOf; template -concept Velocity = physical::QuantityOf; +concept Acceleration = QuantityOf; template -concept Acceleration = physical::QuantityOf; +concept Force = QuantityOf; template -concept Force = physical::QuantityOf; +concept Momentum = QuantityOf; template -concept Momentum = physical::QuantityOf; +concept Energy = QuantityOf; template -concept Energy = physical::QuantityOf; +concept Density = QuantityOf; template -concept Density = physical::QuantityOf; +concept Power = QuantityOf; template -concept Power = physical::QuantityOf; +concept Voltage = QuantityOf; template -concept Voltage = physical::QuantityOf; +concept ElectricCharge = QuantityOf; template -concept ElectricCharge = physical::QuantityOf; +concept Capacitance = QuantityOf; template -concept Capacitance = physical::QuantityOf; +concept SurfaceTension = QuantityOf; template -concept SurfaceTension = physical::QuantityOf; +concept Pressure = QuantityOf; template -concept Pressure = physical::QuantityOf; +concept MagneticInduction = QuantityOf; template -concept MagneticInduction = physical::QuantityOf; +concept MagneticFlux = QuantityOf; template -concept MagneticFlux = physical::QuantityOf; +concept Inductance = QuantityOf; template -concept Inductance = physical::QuantityOf; - -template -concept Conductance = physical::QuantityOf; +concept Conductance = QuantityOf; // TODO Add when downcasting issue is solved // template -// concept Radioactivity = physical::QuantityOf; +// concept Radioactivity = QuantityOf; template -concept CatalyticActivity = physical::QuantityOf; +concept CatalyticActivity = QuantityOf; template -concept AbsorbedDose = physical::QuantityOf; +concept AbsorbedDose = QuantityOf; template -concept CurrentDensity = physical::QuantityOf; +concept CurrentDensity = QuantityOf; template -concept Concentration = physical::QuantityOf; +concept Concentration = QuantityOf; template -concept Luminance = physical::QuantityOf; +concept Luminance = QuantityOf; template -concept DynamicViscosity = physical::QuantityOf; +concept DynamicViscosity = QuantityOf; template -concept HeatCapacity = physical::QuantityOf; +concept HeatCapacity = QuantityOf; template -concept SpecificHeatCapacity = physical::QuantityOf; +concept SpecificHeatCapacity = QuantityOf; template -concept MolarHeatCapacity = physical::QuantityOf; +concept MolarHeatCapacity = QuantityOf; template -concept ThermalConductivity = physical::QuantityOf; +concept ThermalConductivity = QuantityOf; // TODO Add when downcasting issue is solved // template -// concept EnergyDensity = physical::QuantityOf; +// concept EnergyDensity = QuantityOf; template -concept ElectricFieldStrength = physical::QuantityOf; +concept ElectricFieldStrength = QuantityOf; template -concept ChargeDensity = physical::QuantityOf; +concept ChargeDensity = QuantityOf; template -concept SurfaceChargeDensity = physical::QuantityOf; +concept SurfaceChargeDensity = QuantityOf; template -concept Permittivity = physical::QuantityOf; +concept Permittivity = QuantityOf; template -concept Permeability = physical::QuantityOf; +concept Permeability = QuantityOf; template -concept MolarEnergy = physical::QuantityOf; +concept MolarEnergy = QuantityOf; -} // namespace units +} // namespace units::physical diff --git a/src/include/units/physical/iau/length.h b/src/include/units/physical/iau/length.h index f3ca07fd..e7e58d11 100644 --- a/src/include/units/physical/iau/length.h +++ b/src/include/units/physical/iau/length.h @@ -25,7 +25,7 @@ #include -namespace units::iau { +namespace units::physical::iau { // https://en.wikipedia.org/wiki/Light-year struct light_year : named_scaled_unit, si::metre> {}; @@ -49,4 +49,4 @@ constexpr auto operator"" q_angstrom(long double l) { return si::length -namespace units::imperial { +namespace units::physical::imperial { // https://en.wikipedia.org/wiki/Chain_(unit) struct chain : named_scaled_unit, international::yard> {}; @@ -42,4 +42,4 @@ constexpr auto operator"" q_rd(long double l) { return si::length #include -namespace units::international { +namespace units::physical::international { struct square_foot : deduced_unit {}; @@ -37,4 +37,4 @@ constexpr auto operator"" q_ft2(long double l) { return si::area -namespace units::international { +namespace units::physical::international { // international yard // https://en.wikipedia.org/wiki/International_yard_and_pound @@ -94,4 +94,4 @@ constexpr auto operator"" q_mil(long double l) { return si::length #include -namespace units::international { +namespace units::physical::international { struct mile_per_hour : deduced_unit {}; @@ -37,4 +37,4 @@ constexpr auto operator"" q_mi_per_h(long double l) { return si::velocity #include -namespace units::international { +namespace units::physical::international { struct cubic_foot : deduced_unit {}; @@ -37,4 +37,4 @@ constexpr auto operator"" q_ft3(long double l) { return si::volume -namespace units::natural { +namespace units::physical::natural { template inline constexpr auto speed_of_light = velocity(1); -} // namespace units::natural +} // namespace units::physical::natural diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index bd570a61..b3976bfa 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -26,7 +26,7 @@ #include #include -namespace units::natural { +namespace units::physical::natural { struct dim_length : physical::dim_length {}; template @@ -63,4 +63,4 @@ using energy = quantity; // Typical UDLs will not work here as the same units are reused by many quantities. // Should we define some strange ones (i.e. q_mass_GeV)? -} // namespace units::natural +} // namespace units::physical::natural diff --git a/src/include/units/physical/natural/units.h b/src/include/units/physical/natural/units.h index 1277c9eb..7d826957 100644 --- a/src/include/units/physical/natural/units.h +++ b/src/include/units/physical/natural/units.h @@ -25,7 +25,7 @@ #include #include -namespace units::natural { +namespace units::physical::natural { struct unitless : named_unit {}; struct electronvolt : named_unit {}; @@ -38,4 +38,4 @@ struct square_gigaelectronvolt : named_unit #include -namespace units::si { +namespace units::physical::si { struct gray : named_unit {}; struct yoctogray : prefixed_unit {}; @@ -145,4 +145,4 @@ constexpr auto operator"" q_YGy(long double l) { return absorbed_dose #include -namespace units::si { +namespace units::physical::si { struct metre_per_second_sq : unit {}; struct dim_acceleration : physical::dim_acceleration {}; @@ -42,4 +42,4 @@ constexpr auto operator"" q_m_per_s2(long double l) { return acceleration #include -namespace units::si { +namespace units::physical::si { struct square_metre : unit {}; struct dim_area : physical::dim_area {}; @@ -149,4 +149,4 @@ constexpr auto operator"" q_ha(long double l) { return area #include -namespace units::si { +namespace units::physical::si { struct farad : named_unit {}; struct yoctofarad : prefixed_unit {}; @@ -145,4 +145,4 @@ constexpr auto operator"" q_YF(long double l) { return capacitance #include -namespace units::si { +namespace units::physical::si { struct katal : named_unit {}; struct yoctokatal : prefixed_unit {}; @@ -151,5 +151,5 @@ constexpr auto operator"" q_U(long double l) { return catalytic_activity #include -namespace units::si { +namespace units::physical::si { struct coulomb_per_metre_cub : unit {}; struct coulomb_per_metre_sq : unit {}; @@ -54,4 +54,4 @@ constexpr auto operator"" q_C_per_m2(long double l) { return surface_charge_dens } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/concentration.h b/src/include/units/physical/si/concentration.h index f566b9f3..4c6c6220 100644 --- a/src/include/units/physical/si/concentration.h +++ b/src/include/units/physical/si/concentration.h @@ -27,7 +27,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct mol_per_metre_cub : unit {}; struct dim_concentration : physical::dim_concentration {}; @@ -43,5 +43,5 @@ constexpr auto operator"" q_mol_per_m3(long double l) { return concentration #include -namespace units::si { +namespace units::physical::si { struct siemens : named_unit {}; struct yoctosiemens : prefixed_unit {}; @@ -124,5 +124,5 @@ constexpr auto operator"" q_YS(long double l) { return conductance #include -namespace units::si::si2019 { +namespace units::physical::si::si2019 { template inline constexpr auto planck_constant = energy(6.62607015e-34) * time(1); @@ -59,4 +59,4 @@ inline constexpr auto hyperfine_structure_transition_frequency = frequency inline constexpr auto standard_gravity = acceleration(9.80665); -} // namespace units::si::si2019 +} // namespace units::physical::si::si2019 diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index b9b956c8..b4349006 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -26,7 +26,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct ampere : named_unit {}; struct yoctoampere : prefixed_unit {}; @@ -143,4 +143,4 @@ constexpr auto operator"" q_YA(long double l) { return current #include -namespace units::si { +namespace units::physical::si { struct ampere_per_metre_sq : unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_A_per_m2(long double l) { return current_density #include -namespace units::si { +namespace units::physical::si { struct kilogram_per_metre_cub : unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_kg_per_m3(long double l) { return density #include -namespace units::si { +namespace units::physical::si { struct pascal_second : unit {}; struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity {}; @@ -43,5 +43,5 @@ constexpr auto operator"" q_Pa_s(long double l) { return dynamic_viscosity #include -namespace units::si { +namespace units::physical::si { struct coulomb : named_unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_C(long double l) { return electric_charge #include -namespace units::si { +namespace units::physical::si { struct volt_per_metre : unit {}; struct dim_electric_field_strength : physical::dim_electric_field_strength {}; @@ -42,4 +42,4 @@ constexpr auto operator"" q_V_per_m(long double l) { return electric_field_stren } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index 48b4d3a2..54848946 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -27,7 +27,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct joule : named_unit {}; struct yoctojoule : prefixed_unit {}; @@ -135,4 +135,4 @@ constexpr auto operator"" q_GeV(long double l) { return energy #include -namespace units::si { +namespace units::physical::si { struct newton : named_unit {}; struct yoctonewton : prefixed_unit {}; @@ -145,4 +145,4 @@ constexpr auto operator"" q_YN(long double l) { return force #include -namespace units::si { +namespace units::physical::si { struct hertz : named_unit {}; struct yoctohertz : prefixed_unit {}; @@ -123,4 +123,4 @@ constexpr auto operator"" q_YHz(long double l) { return frequency #include -namespace units::si { +namespace units::physical::si { struct joule_per_kelvin : unit {}; struct joule_per_kilogram_kelvin : unit {}; @@ -64,5 +64,5 @@ constexpr auto operator"" q_J_per_mol_K(long double l) { return molar_heat_capac } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/inductance.h b/src/include/units/physical/si/inductance.h index 6eeef43e..105a17cb 100644 --- a/src/include/units/physical/si/inductance.h +++ b/src/include/units/physical/si/inductance.h @@ -27,7 +27,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct henry : named_unit {}; @@ -125,4 +125,4 @@ constexpr auto operator"" q_YH(long double l) { return inductance #include -namespace units::si { +namespace units::physical::si { struct metre : named_unit {}; struct yoctometre : prefixed_unit {}; @@ -149,4 +149,4 @@ constexpr auto operator"" q_au(long double l) { return length #include -namespace units::si { +namespace units::physical::si { struct candela_per_metre_sq : unit {}; struct dim_luminance : physical::dim_luminance {}; @@ -43,5 +43,5 @@ constexpr auto operator"" q_cd_per_m2(long double l) { return luminance #include -namespace units::si { +namespace units::physical::si { struct candela : named_unit {}; struct yoctocandela : prefixed_unit {}; @@ -143,4 +143,4 @@ constexpr auto operator"" q_Ycd(long double l) { return luminous_intensity #include -namespace units::si { +namespace units::physical::si { struct weber : named_unit {}; @@ -125,4 +125,4 @@ constexpr auto operator"" q_YWb(long double l) { return magnetic_flux #include -namespace units::si { +namespace units::physical::si { struct tesla : named_unit {}; diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index f72aef2a..7a5e3337 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -26,7 +26,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct gram : named_unit {}; struct yoctogram : prefixed_unit {}; @@ -255,4 +255,4 @@ constexpr auto operator"" q_Da(long double l) { return mass } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/molar_energy.h b/src/include/units/physical/si/molar_energy.h index 6e3cb432..6d8b5d64 100644 --- a/src/include/units/physical/si/molar_energy.h +++ b/src/include/units/physical/si/molar_energy.h @@ -28,7 +28,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct joule_per_mole : unit {}; @@ -45,4 +45,4 @@ constexpr auto operator"" q_J_per_mol(long double l) { return molar_energy #include -namespace units::si { +namespace units::physical::si { struct kilogram_metre_per_second : unit {}; struct dim_momentum : physical::dim_momentum {}; @@ -43,4 +43,4 @@ constexpr auto operator"" q_kg_m_per_s(long double l) { return momentum #include -namespace units::si { +namespace units::physical::si { struct henry_per_metre : unit {}; @@ -44,5 +44,5 @@ constexpr auto operator"" q_H_per_m(long double l) { return permeability #include -namespace units::si { +namespace units::physical::si { struct farad_per_metre : unit {}; @@ -44,5 +44,5 @@ constexpr auto operator"" q_F_per_m(long double l) { return permittivity #include -namespace units::si { +namespace units::physical::si { struct watt : named_unit {}; struct yoctowatt : prefixed_unit {}; @@ -124,4 +124,4 @@ constexpr auto operator"" q_YW(long double l) { return power -namespace units::si { +namespace units::physical::si { struct prefix : prefix_family {}; @@ -51,4 +51,4 @@ struct zetta : units::prefix> struct yotta : units::prefix> {}; // clang-format on -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index dd6f987c..6f68ce52 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -28,7 +28,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct pascal : named_unit {}; struct yoctopascal : prefixed_unit {}; @@ -145,4 +145,4 @@ constexpr auto operator"" q_YPa(long double l) { return pressure #include -namespace units::si { +namespace units::physical::si { struct ohm : named_unit {}; struct yoctoohm : prefixed_unit {}; @@ -125,4 +125,4 @@ constexpr auto operator"" q_YR(long double l) { return resistance #include -namespace units::si { +namespace units::physical::si { struct mole : named_unit {}; @@ -43,4 +43,4 @@ constexpr auto operator"" q_mol(long double l) { return substance #include -namespace units::si { +namespace units::physical::si { struct newton_per_metre : unit {}; @@ -43,4 +43,4 @@ inline namespace literals { } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index 79ee6398..cf016ebc 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -25,7 +25,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct kelvin : named_unit {}; @@ -42,4 +42,4 @@ constexpr auto operator"" q_K(long double l) { return temperature #include -namespace units::si { +namespace units::physical::si { struct watt_per_metre_kelvin : unit {}; @@ -44,4 +44,4 @@ constexpr auto operator"" q_W_per_m_K(long double l) { return thermal_conductivi } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index 16409534..b3778bd8 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -26,7 +26,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct second : named_unit {}; struct yoctosecond : prefixed_unit {}; @@ -98,4 +98,4 @@ constexpr auto operator"" q_d(long double l) { return time(l); } // namespace literals -} // namespace units::si +} // namespace units::physical::si diff --git a/src/include/units/physical/si/velocity.h b/src/include/units/physical/si/velocity.h index 7507da44..8a33fcde 100644 --- a/src/include/units/physical/si/velocity.h +++ b/src/include/units/physical/si/velocity.h @@ -27,7 +27,7 @@ #include #include -namespace units::si { +namespace units::physical::si { struct metre_per_second : unit {}; struct dim_velocity : physical::dim_velocity {}; @@ -49,4 +49,4 @@ constexpr auto operator"" q_km_per_h(long double l) { return velocity #include -namespace units::si { +namespace units::physical::si { struct volt : named_unit {}; struct yoctovolt : prefixed_unit {}; @@ -145,4 +145,4 @@ constexpr auto operator"" q_YV(long double l) { return voltage #include -namespace units::si { +namespace units::physical::si { struct cubic_metre : unit {}; struct dim_volume : physical::dim_volume {}; @@ -249,4 +249,4 @@ constexpr auto operator"" q_Yl(long double l) { return volume -namespace units::typographic { +namespace units::physical::typographic { // TODO Conflicts with (https://en.wikipedia.org/wiki/Pica_(typography)), verify correctness of below conversion factors and provide hyperlinks to definitions struct pica_comp : named_scaled_unit, si::metre> {}; @@ -53,4 +53,4 @@ constexpr auto operator"" q_point_prn(long double l) { return si::length -namespace units::us { +namespace units::physical::us { // https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot // https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6 @@ -40,17 +40,17 @@ struct mile : named_scaled_unit, us::foot inline namespace literals { // ft -constexpr auto operator"" q_ft_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" q_ft_us(long double l) { return si::length(l); } +constexpr auto operator"" q_ft_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_ft_us(long double l) { return si::length(l); } // fathom -constexpr auto operator"" q_fathom_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" q_fathom_us(long double l) { return si::length(l); } +constexpr auto operator"" q_fathom_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_fathom_us(long double l) { return si::length(l); } // ft -constexpr auto operator"" q_mi_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" q_mi_us(long double l) { return si::length(l); } +constexpr auto operator"" q_mi_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_mi_us(long double l) { return si::length(l); } } // namespace literals -} // namespace units::us +} // namespace units::physical::us diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index e160494d..7235ebb6 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -320,7 +320,7 @@ struct cast_ratio { * * This cast gets the target quantity type to cast to. For example: * - * auto q1 = units::quantity_cast>(1q_ms); + * auto q1 = units::quantity_cast>(1q_ms); * * @tparam To a target quantity type to cast to */ @@ -344,7 +344,7 @@ template * * This cast gets only the target dimension to cast to. For example: * - * auto q1 = units::quantity_cast(200q_Gal); + * auto q1 = units::quantity_cast(200q_Gal); * * @tparam ToD a dimension type to use for a target quantity */ @@ -363,7 +363,7 @@ template * * This cast gets only the target unit to cast to. For example: * - * auto q1 = units::quantity_cast(1q_ms); + * auto q1 = units::quantity_cast(1q_ms); * * @tparam ToU a unit type to use for a target quantity */ diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index 4d306f5e..e08e623c 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -37,7 +37,8 @@ #include using namespace units; -using namespace units::si; +using namespace units::physical; +using namespace units::physical::si; using namespace Catch::Matchers; TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") @@ -290,7 +291,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("surface tension") { - struct newton_per_centimetre : deduced_unit {}; + struct newton_per_centimetre : deduced_unit {}; const surface_tension q(123); os << q; diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 474ecff3..905bb3b2 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -32,12 +32,12 @@ #include "units/format.h" #include -using namespace units::si; -using namespace units::international; -using namespace units::us; -using namespace units::iau; -using namespace units::imperial; -using namespace units::typographic; +using namespace units::physical::si; +using namespace units::physical::international; +using namespace units::physical::us; +using namespace units::physical::iau; +using namespace units::physical::imperial; +using namespace units::physical::typographic; TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") { diff --git a/test/unit_test/runtime/math_test.cpp b/test/unit_test/runtime/math_test.cpp index 617c1e5f..fc33ad3e 100644 --- a/test/unit_test/runtime/math_test.cpp +++ b/test/unit_test/runtime/math_test.cpp @@ -26,7 +26,7 @@ #include using namespace units; -using namespace units::si; +using namespace units::physical::si; // classical diff --git a/test/unit_test/static/cgs_test.cpp b/test/unit_test/static/cgs_test.cpp index ac33c0f3..30140e48 100644 --- a/test/unit_test/static/cgs_test.cpp +++ b/test/unit_test/static/cgs_test.cpp @@ -34,7 +34,7 @@ namespace { using namespace units; -using namespace units::cgs; +using namespace units::physical::cgs; /* ************** BASE DIMENSIONS **************** */ diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index 477e07e5..acb74a08 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -165,7 +165,7 @@ struct quantity_values> { namespace { -using namespace units::si; +using namespace units::physical::si; // constructors diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index 08921a8c..b2e4aff1 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -29,7 +29,7 @@ namespace { using namespace units; -using namespace units::si; +using namespace units::physical::si; // power spectral density struct sq_volt_per_hertz : unit {}; @@ -60,8 +60,8 @@ static_assert(std::is_same_v {}; -struct dim_mass_rate : derived_dimension, units::exp> {}; -struct kilogram_per_hour : deduced_unit {}; +struct dim_mass_rate : derived_dimension, units::exp> {}; +struct kilogram_per_hour : deduced_unit {}; constexpr auto a = 1q_kg / 1q_h; static_assert(std::is_same_v); diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index c70dcbaa..88689de0 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -25,7 +25,7 @@ namespace { -using namespace units; +using namespace units::physical; static_assert(Length>); static_assert(!Length>); diff --git a/test/unit_test/static/math_test.cpp b/test/unit_test/static/math_test.cpp index fa4a3b2e..ab4c04fa 100644 --- a/test/unit_test/static/math_test.cpp +++ b/test/unit_test/static/math_test.cpp @@ -27,8 +27,8 @@ namespace { - using namespace units::si::literals; - using namespace units::international::literals; + using namespace units::physical::si::literals; + using namespace units::physical::international::literals; static_assert(std::is_same_v(2q_m)), std::int64_t>); static_assert(std::is_same_v(2q_m)), decltype(2q_m)>); diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index d7c5c687..a5770f2a 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -31,7 +31,7 @@ namespace { using namespace units; -using namespace units::si; +using namespace units::physical::si; // class invariants @@ -135,24 +135,24 @@ static_assert( static_assert(std::is_same_v() * 1.0), length>); static_assert(std::is_same_v()), length>); static_assert( - std::is_same_v() * si::time()), length>); + std::is_same_v() * physical::si::time()), length>); static_assert( - std::is_same_v() * si::time()), length, metre>, int>>); -static_assert(std::is_same_v() * si::time()), + std::is_same_v() * physical::si::time()), length, metre>, int>>); +static_assert(std::is_same_v() * physical::si::time()), quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); -static_assert(std::is_same_v()), frequency>); -static_assert(std::is_same_v()), frequency, hertz>, int>>); -static_assert(std::is_same_v()), si::time>); +static_assert(std::is_same_v()), frequency>); +static_assert(std::is_same_v()), frequency, hertz>, int>>); +static_assert(std::is_same_v()), physical::si::time>); static_assert(std::is_same_v()), quantity>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v() / 1.0), length>); static_assert(std::is_same_v() / length()), double>); static_assert(std::is_same_v() / length()), double>); static_assert( - std::is_same_v() / si::time()), velocity>); + std::is_same_v() / physical::si::time()), velocity>); static_assert( - std::is_same_v() / si::time()), velocity, metre_per_second>>>); -static_assert(std::is_same_v() / length()), + std::is_same_v() / physical::si::time()), velocity, metre_per_second>>>); +static_assert(std::is_same_v() / length()), quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v() % short(1)), length>); static_assert(std::is_same_v() % length(1)), length>); diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp index 8af2f99c..37abe968 100644 --- a/test/unit_test/static/si_cgs_test.cpp +++ b/test/unit_test/static/si_cgs_test.cpp @@ -44,7 +44,7 @@ namespace { -using namespace units; +using namespace units::physical; static_assert(cgs::length(100) == si::length(1)); static_assert(cgs::mass(1'000) == si::mass(1)); @@ -59,7 +59,7 @@ static_assert(cgs::pressure(10) == si::pressure(1)); namespace si_test { -using namespace units::si::literals; +using namespace units::physical::si::literals; static_assert(cgs::length(100) == 1q_m); static_assert(cgs::mass(1'000) == 1q_kg); @@ -75,7 +75,7 @@ static_assert(cgs::pressure(10) == 1q_Pa); namespace cgs_test { -using namespace units::cgs::literals; +using namespace units::physical::cgs::literals; static_assert(100q_cm == si::length(1)); static_assert(1'000q_g == si::mass(1)); @@ -91,8 +91,8 @@ static_assert(10q_Ba == si::pressure(1)); namespace both_test { -using namespace units::si::literals; -using namespace units::cgs::literals; +using namespace units::physical::si::literals; +using namespace units::physical::cgs::literals; // static_assert(100q_cm == 1q_m); // ambiguous // static_assert(1'000q_g == 1q_kg); // ambiguous diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index f7dd6898..21f83b1c 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -26,7 +26,7 @@ namespace { using namespace units; -using namespace units::si; +using namespace units::physical::si; /* ************** BASE DIMENSIONS **************** */ diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index c0ecd215..6f6cc477 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -26,6 +26,7 @@ namespace { using namespace units; +using namespace units::physical; struct metre : named_unit {}; struct centimetre : prefixed_unit {}; diff --git a/test/unit_test/static/us_test.cpp b/test/unit_test/static/us_test.cpp index 7b7d8f60..387dce1d 100644 --- a/test/unit_test/static/us_test.cpp +++ b/test/unit_test/static/us_test.cpp @@ -34,9 +34,9 @@ namespace { using namespace units; -using namespace units::si; -using namespace units::us; -using namespace units::international; +using namespace units::physical::si; +using namespace units::physical::us; +using namespace units::physical::international; /* ************** BASE DIMENSIONS **************** */ diff --git a/test_package/test_package.cpp b/test_package/test_package.cpp index 901168ff..efd7116f 100644 --- a/test_package/test_package.cpp +++ b/test_package/test_package.cpp @@ -30,6 +30,6 @@ constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO int main() { - using namespace units::si::literals; + using namespace units::physical::si::literals; std::cout << "Average speed = " << avg_speed(240.q_km, 2q_h) << '\n'; }