From c3d7359ca372675b485cdacfd705028f956390dd Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 18 Sep 2019 21:55:16 -0600 Subject: [PATCH] `units` removed from a `std::experimental` namespace --- README.md | 2 +- doc/DESIGN.md | 18 +++++++++--------- example/example.cpp | 19 +++++++++---------- src/include/units/bits/concepts.h | 4 ++-- src/include/units/bits/downcasting.h | 4 ++-- src/include/units/bits/type_list.h | 4 ++-- src/include/units/bits/type_traits.h | 2 +- src/include/units/dimension.h | 4 ++-- src/include/units/dimensions/acceleration.h | 4 ++-- src/include/units/dimensions/area.h | 4 ++-- .../units/dimensions/base_dimensions.h | 4 ++-- src/include/units/dimensions/capacitance.h | 4 ++-- src/include/units/dimensions/current.h | 4 ++-- .../units/dimensions/electric_charge.h | 4 ++-- src/include/units/dimensions/energy.h | 4 ++-- src/include/units/dimensions/force.h | 4 ++-- src/include/units/dimensions/frequency.h | 4 ++-- src/include/units/dimensions/length.h | 4 ++-- .../units/dimensions/luminous_intensity.h | 4 ++-- src/include/units/dimensions/mass.h | 4 ++-- src/include/units/dimensions/power.h | 4 ++-- src/include/units/dimensions/pressure.h | 4 ++-- src/include/units/dimensions/substance.h | 4 ++-- src/include/units/dimensions/temperature.h | 4 ++-- src/include/units/dimensions/time.h | 4 ++-- src/include/units/dimensions/velocity.h | 4 ++-- src/include/units/dimensions/voltage.h | 4 ++-- src/include/units/dimensions/volume.h | 4 ++-- src/include/units/math.h | 4 ++-- src/include/units/quantity.h | 4 ++-- src/include/units/ratio.h | 4 ++-- src/include/units/unit.h | 8 ++++---- .../list/type_list_concepts_all.cpp.erb | 4 +--- test/metabench/list/type_list_concepts_all.h | 4 ++-- .../list/type_list_concepts_iface.cpp.erb | 4 +--- .../metabench/list/type_list_concepts_iface.h | 4 ++-- .../list/type_list_concepts_no.cpp.erb | 4 +--- test/metabench/list/type_list_concepts_no.h | 4 ++-- .../list/type_list_conditional_alias.cpp.erb | 4 +--- .../list/type_list_conditional_alias.h | 4 ++-- .../type_list_conditional_alias_hard.cpp.erb | 4 +--- .../list/type_list_conditional_alias_hard.h | 4 ++-- .../list/type_list_conditional_std.cpp.erb | 4 +--- .../list/type_list_conditional_std.h | 4 ++-- .../make_dimension/concepts_all.cpp.erb | 8 +++----- .../make_dimension/concepts_iface.cpp.erb | 8 +++----- .../make_dimension/dimension_concepts_all.h | 4 ++-- .../make_dimension/dimension_concepts_iface.h | 4 ++-- .../make_dimension/dimension_no_concepts.h | 4 ++-- .../make_dimension/downcasting_concepts_all.h | 4 ++-- .../make_dimension/downcasting_no_concepts.h | 4 ++-- .../make_dimension/no_concepts.cpp.erb | 8 +++----- .../make_dimension/ratio_concepts_all.h | 4 ++-- .../make_dimension/ratio_concepts_iface.h | 4 ++-- .../make_dimension/ratio_no_concepts.h | 4 ++-- .../make_dimension/type_list_concepts_all.h | 4 ++-- .../make_dimension/type_list_concepts_iface.h | 4 ++-- .../make_dimension/type_list_no_concepts.h | 4 ++-- test/metabench/make_dimension/type_traits.h | 2 +- .../ratio/all_ratio_type_constexpr.cpp.erb | 12 +++++------- test/metabench/ratio/all_std_ratio.cpp.erb | 4 +--- .../common_ratio_ratio_type_constexpr.cpp.erb | 8 +++----- .../ratio/common_ratio_std_ratio.cpp.erb | 4 +--- .../ratio/create_ratio_type_constexpr.cpp.erb | 6 ++---- ...ltiply_divide_ratio_type_constexpr.cpp.erb | 10 ++++------ test/metabench/ratio/ratio_type_constexpr.h | 4 ++-- test/metabench/ratio/std_ratio.h | 4 ++-- test/unit_test/test_custom_units.cpp | 14 +++++--------- test/unit_test/test_dimension.cpp | 2 +- test/unit_test/test_quantity.cpp | 8 ++++---- test/unit_test/test_ratio.cpp | 2 +- test/unit_test/test_type_list.cpp | 2 +- test/unit_test/test_units.cpp | 2 +- test_package/test_package.cpp | 7 +++---- 74 files changed, 164 insertions(+), 200 deletions(-) diff --git a/README.md b/README.md index b84d40d1..11df05a6 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ NOTE: This library as of now compiles correctly only with gcc-9.1 and newer. ## Release notes - 0.4.0 ??? - - + - `units` removed from a `std::experimental` namespace - 0.3.1 Sep 18, 2019 - cmcstl2 dependency changed to range-v3 0.9.1 diff --git a/doc/DESIGN.md b/doc/DESIGN.md index 8e3fb2d2..265b1303 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -51,7 +51,7 @@ Quantity is a concrete amount of a unit for a specified dimension with a specifi ```cpp units::quantity d1(123); -auto d2 = 123km; // stde::units::quantity +auto d2 = 123km; // units::quantity ``` There are C++ concepts provided for each such quantity type: @@ -385,7 +385,7 @@ could generate a following compile time error: const Velocity auto t = 20s; ^~~~ In file included from \example\example.cpp:23: -/src/include/units/si/velocity.h:41:16: note: within 'template concept const bool stde::units::Velocity [with T = stde::units::quantity >, std::ratio<1> >, long long int>]' +/src/include/units/si/velocity.h:41:16: note: within 'template concept const bool units::Velocity [with T = units::quantity >, std::ratio<1> >, long long int>]' concept Velocity = Quantity && std::same_as; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, @@ -393,7 +393,7 @@ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/si/base_dimensions.h:25, from /src/include/units/si/velocity.h:25, from \example\example.cpp:23: -/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::same_as [with T = stde::units::dimension >; U = stde::units::dimension,stde::units::exp >]' +/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::same_as [with T = units::dimension >; U = units::dimension,units::exp >]' concept same_as = std::is_same_v; ^~~~ /src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false @@ -403,13 +403,13 @@ Time and velocity are not that complicated dimensions and there are much more co out there, but even for those dimensions ```text -[with T = stde::units::quantity >, std::ratio<1> >, long long int>] +[with T = units::quantity >, std::ratio<1> >, long long int>] ``` and ```text -[with T = stde::units::dimension >; U = stde::units::dimension,stde::units::exp >] +[with T = units::dimension >; U = units::dimension,units::exp >] ``` starts to be really hard to analyze or debug. @@ -422,7 +422,7 @@ same code will result with such an error: const Velocity t = 20s; ^~~~ In file included from \example\example.cpp:23: -/src/include/units/si/velocity.h:48:16: note: within 'template concept const bool stde::units::Velocity [with T = stde::units::quantity]' +/src/include/units/si/velocity.h:48:16: note: within 'template concept const bool units::Velocity [with T = units::quantity]' concept Velocity = Quantity && std::same_as; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, @@ -430,7 +430,7 @@ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/si/base_dimensions.h:25, from /src/include/units/si/velocity.h:25, from \example\example.cpp:23: -/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::same_as [with T = stde::units::time; U = stde::units::velocity]' +/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::same_as [with T = units::time; U = units::velocity]' concept same_as = std::is_same_v; ^~~~ /src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false @@ -439,13 +439,13 @@ In file included from /src/include/units/bits/tools.h:25, Now ```text -[with T = stde::units::quantity] +[with T = units::quantity] ``` and ```text -[with T = stde::units::time; U = stde::units::velocity] +[with T = units::time; U = units::velocity] ``` are not arguably much easier to understand thus provide better user experience. diff --git a/example/example.cpp b/example/example.cpp index 27685ce1..a4424a7d 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -25,28 +25,27 @@ namespace { -namespace stde = std::experimental; -using namespace stde::units::literals; +using namespace units::literals; -template -constexpr stde::units::Velocity avg_speed(D d, T t) +template +constexpr units::Velocity avg_speed(D d, T t) { return d / t; } -template +template void example_1(V v, T t) { - const stde::units::Length distance = v * t; + const units::Length distance = v * t; std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass " - << stde::units::quantity_cast>(distance).count() << " metres.\n"; + << units::quantity_cast>(distance).count() << " metres.\n"; } void example_2(double distance_v, double duration_v) { - stde::units::quantity distance(distance_v); - stde::units::quantity duration(duration_v); - const auto kmph = quantity_cast(avg_speed(distance, duration)); + units::quantity distance(distance_v); + units::quantity duration(duration_v); + const auto kmph = quantity_cast(avg_speed(distance, duration)); std::cout << "Average speed of a car that makes " << distance.count() << " km in " << duration.count() << " hours is " << kmph.count() << " km/h.\n"; } diff --git a/src/include/units/bits/concepts.h b/src/include/units/bits/concepts.h index c8b4d0ef..c9d2269e 100644 --- a/src/include/units/bits/concepts.h +++ b/src/include/units/bits/concepts.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { template concept bool Number = std::regular && @@ -43,4 +43,4 @@ namespace std::experimental::units { // … }; -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/bits/downcasting.h b/src/include/units/bits/downcasting.h index c80881a2..d27b9a51 100644 --- a/src/include/units/bits/downcasting.h +++ b/src/include/units/bits/downcasting.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { template struct downcast_base { @@ -51,4 +51,4 @@ namespace std::experimental::units { template using downcasting_traits_t = downcasting_traits::type; -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/bits/type_list.h b/src/include/units/bits/type_list.h index 30ba1f0a..7a720d66 100644 --- a/src/include/units/bits/type_list.h +++ b/src/include/units/bits/type_list.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { namespace detail { @@ -182,4 +182,4 @@ namespace std::experimental::units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/bits/type_traits.h b/src/include/units/bits/type_traits.h index a2928c5b..4a9c8a50 100644 --- a/src/include/units/bits/type_traits.h +++ b/src/include/units/bits/type_traits.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { namespace detail { diff --git a/src/include/units/dimension.h b/src/include/units/dimension.h index 38d09fa3..6ecd45bd 100644 --- a/src/include/units/dimension.h +++ b/src/include/units/dimension.h @@ -27,7 +27,7 @@ #include #include -namespace std::experimental::units { +namespace units { template concept bool BaseDimension = std::is_empty_v && @@ -286,4 +286,4 @@ namespace std::experimental::units { template using dimension_pow_t = dimension_pow::type; -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/acceleration.h b/src/include/units/dimensions/acceleration.h index dfb8efc5..ac68bf83 100644 --- a/src/include/units/dimensions/acceleration.h +++ b/src/include/units/dimensions/acceleration.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { struct acceleration : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -43,4 +43,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/area.h b/src/include/units/dimensions/area.h index c111b6ee..b0fd45ba 100644 --- a/src/include/units/dimensions/area.h +++ b/src/include/units/dimensions/area.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { struct area : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -67,4 +67,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/base_dimensions.h b/src/include/units/dimensions/base_dimensions.h index 732e88e0..81314a0b 100644 --- a/src/include/units/dimensions/base_dimensions.h +++ b/src/include/units/dimensions/base_dimensions.h @@ -24,7 +24,7 @@ #include -namespace std::experimental::units { +namespace units { struct base_dim_length { static constexpr const char* value = "length"; }; struct base_dim_mass { static constexpr const char* value = "mass"; }; @@ -34,4 +34,4 @@ namespace std::experimental::units { struct base_dim_substance { static constexpr const char* value = "substance"; }; struct base_dim_luminous_intensity { static constexpr const char* value = "luminous intensity"; }; -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/capacitance.h b/src/include/units/dimensions/capacitance.h index 770cacb9..41436eb3 100644 --- a/src/include/units/dimensions/capacitance.h +++ b/src/include/units/dimensions/capacitance.h @@ -26,7 +26,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct capacitance : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -45,4 +45,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/current.h b/src/include/units/dimensions/current.h index a9adc210..275ba564 100644 --- a/src/include/units/dimensions/current.h +++ b/src/include/units/dimensions/current.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct current : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace std::experimental::units { } -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/electric_charge.h b/src/include/units/dimensions/electric_charge.h index f634ce71..195eda18 100644 --- a/src/include/units/dimensions/electric_charge.h +++ b/src/include/units/dimensions/electric_charge.h @@ -26,7 +26,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct electric_charge : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -45,4 +45,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/energy.h b/src/include/units/dimensions/energy.h index c1acfca1..49fc59b6 100644 --- a/src/include/units/dimensions/energy.h +++ b/src/include/units/dimensions/energy.h @@ -26,7 +26,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct energy : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -45,4 +45,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/force.h b/src/include/units/dimensions/force.h index f67ca285..c4d9b2c8 100644 --- a/src/include/units/dimensions/force.h +++ b/src/include/units/dimensions/force.h @@ -26,7 +26,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct force : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -45,4 +45,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/frequency.h b/src/include/units/dimensions/frequency.h index 528cd23e..19c9fe7b 100644 --- a/src/include/units/dimensions/frequency.h +++ b/src/include/units/dimensions/frequency.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct frequency : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -79,4 +79,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/length.h b/src/include/units/dimensions/length.h index fefb59bc..f02506f3 100644 --- a/src/include/units/dimensions/length.h +++ b/src/include/units/dimensions/length.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct length : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -99,4 +99,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/luminous_intensity.h b/src/include/units/dimensions/luminous_intensity.h index e4d84c12..21263247 100644 --- a/src/include/units/dimensions/luminous_intensity.h +++ b/src/include/units/dimensions/luminous_intensity.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct luminous_intensity : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/mass.h b/src/include/units/dimensions/mass.h index 312e6bf7..432b4bb3 100644 --- a/src/include/units/dimensions/mass.h +++ b/src/include/units/dimensions/mass.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct mass : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -51,4 +51,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/power.h b/src/include/units/dimensions/power.h index ca309ca1..1e8cd408 100644 --- a/src/include/units/dimensions/power.h +++ b/src/include/units/dimensions/power.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct power : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/pressure.h b/src/include/units/dimensions/pressure.h index 8c630bc8..0b7c6bac 100644 --- a/src/include/units/dimensions/pressure.h +++ b/src/include/units/dimensions/pressure.h @@ -26,7 +26,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct pressure : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -45,4 +45,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/substance.h b/src/include/units/dimensions/substance.h index b8864268..64ab5513 100644 --- a/src/include/units/dimensions/substance.h +++ b/src/include/units/dimensions/substance.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct substance : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/temperature.h b/src/include/units/dimensions/temperature.h index 6ed30694..5ec92eef 100644 --- a/src/include/units/dimensions/temperature.h +++ b/src/include/units/dimensions/temperature.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct temperature : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace std::experimental::units { } // namespace literals -} // namespace std::experimental::units +} // namespace units diff --git a/src/include/units/dimensions/time.h b/src/include/units/dimensions/time.h index 290c7c8b..fa198b0b 100644 --- a/src/include/units/dimensions/time.h +++ b/src/include/units/dimensions/time.h @@ -25,7 +25,7 @@ #include #include -namespace std::experimental::units { +namespace units { struct time : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to