From 1d94eb93e842ee93e56f932321c31a66b6afb768 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 6 Aug 2019 19:56:09 +0200 Subject: [PATCH] dimension_ prefix removed from names of derived dimensions --- README.md | 3 +- doc/DESIGN.md | 30 +++++++++---------- src/include/units/dimensions/acceleration.h | 8 ++--- src/include/units/dimensions/area.h | 16 +++++----- src/include/units/dimensions/capacitance.h | 8 ++--- src/include/units/dimensions/current.h | 8 ++--- .../units/dimensions/electric_charge.h | 8 ++--- src/include/units/dimensions/energy.h | 8 ++--- src/include/units/dimensions/force.h | 8 ++--- src/include/units/dimensions/frequency.h | 8 ++--- src/include/units/dimensions/length.h | 16 +++++----- .../units/dimensions/luminous_intensity.h | 8 ++--- src/include/units/dimensions/mass.h | 8 ++--- src/include/units/dimensions/power.h | 8 ++--- src/include/units/dimensions/pressure.h | 8 ++--- src/include/units/dimensions/substance.h | 8 ++--- src/include/units/dimensions/temperature.h | 8 ++--- src/include/units/dimensions/time.h | 12 ++++---- src/include/units/dimensions/velocity.h | 12 ++++---- src/include/units/dimensions/voltage.h | 8 ++--- src/include/units/dimensions/volume.h | 16 +++++----- 21 files changed, 109 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index c86d4dc3..368dcd74 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![AppVeyor](https://img.shields.io/appveyor/ci/mpusz/units/master.svg?label=AppVeyor)](https://ci.appveyor.com/project/mpusz/units) [![Download](https://api.bintray.com/packages/mpusz/conan-mpusz/mp-units%3Ampusz/images/download.svg) ](https://bintray.com/mpusz/conan-mpusz/mp-units%3Ampusz/_latestVersion) -# `units` - Physical Units Library for C++ +# `units` - A Units Library for C++ ## Summary @@ -66,6 +66,7 @@ NOTE: This library as of now compiles correctly only with gcc-9.1 and newer. - `meter` renamed to `metre` - Missing `operator*` added - Predefined dimensions moved to a dedicated directory + - `dimension_` prefix removed from names of derived dimensions - 0.2.0 July 18, 2019 - Added C++20 features supported by gcc-9.1 (std::remove_cvref_t, down with typename, std::type_identity) diff --git a/doc/DESIGN.md b/doc/DESIGN.md index 04fc23f8..d9823225 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -58,7 +58,7 @@ There are C++ concepts provided for each such quantity type: ```cpp template -concept Length = Quantity && std::Same; +concept Length = Quantity && std::Same; ``` With that we can easily write a function template like this: @@ -158,10 +158,10 @@ template using make_dimension_t = make_dimension::type; ``` -So for example to create a `dimension_velocity` type we have to do: +So for example to create a `velocity` type we have to do: ```cpp -struct dimension_velocity : make_dimension_t, exp> {}; +struct velocity : make_dimension_t, exp> {}; ``` In order to make `make_dimension_t` work as expected it has to provide unique ordering for @@ -323,7 +323,7 @@ could generate a following compile time error: ^~~~ 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>]' - concept Velocity = Quantity && std::Same; + concept Velocity = Quantity && std::Same; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/dimension.h:25, @@ -360,14 +360,14 @@ same code will result with such an error: ^~~~ 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]' - concept Velocity = Quantity && std::Same; + concept Velocity = Quantity && std::Same; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/dimension.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 [with T = stde::units::dimension_time; U = stde::units::dimension_velocity]' +/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::Same [with T = stde::units::time; U = stde::units::velocity]' concept Same = std::is_same_v; ^~~~ /src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false @@ -382,7 +382,7 @@ Now and ```text -[with T = stde::units::dimension_time; U = stde::units::dimension_velocity] +[with T = stde::units::time; U = stde::units::velocity] ``` are not arguably much easier to understand thus provide better user experience. @@ -419,12 +419,12 @@ using downcasting_traits_t = downcasting_traits::type; With that the downcasting functionality is enabled by: ```cpp -struct dimension_length : make_dimension_t> {}; -template<> struct downcasting_traits> : downcast_to {}; +struct length : make_dimension_t> {}; +template<> struct downcasting_traits> : downcast_to {}; ``` ```cpp -struct kilometre : unit {}; +struct kilometre : unit {}; template<> struct downcasting_traits> : downcast_to {}; ``` @@ -436,15 +436,15 @@ In order to extend the library with custom dimensions the user has to: downcasting trait for it: ```cpp -struct dimension_velocity : make_dimension_t, exp> {}; -template<> struct downcasting_traits> : downcast_to {}; +struct velocity : make_dimension_t, exp> {}; +template<> struct downcasting_traits> : downcast_to {}; ``` 2. Define a concept that will match a new dimension: ```cpp template -concept Velocity = Quantity && std::Same; +concept Velocity = Quantity && std::Same; ``` 3. Define units and provide downcasting traits for them: @@ -452,7 +452,7 @@ concept Velocity = Quantity && std::Same> {}; +struct metre : unit> {}; template<> struct downcasting_traits> : downcast_to {}; ``` @@ -466,7 +466,7 @@ template<> struct downcasting_traits> : downcast_to {}; +struct kilometre_per_hour : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; ``` diff --git a/src/include/units/dimensions/acceleration.h b/src/include/units/dimensions/acceleration.h index d3c43e58..ec1ddbb0 100644 --- a/src/include/units/dimensions/acceleration.h +++ b/src/include/units/dimensions/acceleration.h @@ -26,13 +26,13 @@ namespace std::experimental::units { - struct dimension_acceleration : make_dimension_t, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct acceleration : make_dimension_t, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Acceleration = Quantity && std::Same; + concept bool Acceleration = Quantity && std::Same; - struct metre_per_second_sq : derived_unit {}; + struct metre_per_second_sq : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/area.h b/src/include/units/dimensions/area.h index 5245f13c..9a565f58 100644 --- a/src/include/units/dimensions/area.h +++ b/src/include/units/dimensions/area.h @@ -26,25 +26,25 @@ namespace std::experimental::units { - struct dimension_area : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct area : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Area = Quantity && std::Same; + concept bool Area = Quantity && std::Same; - struct square_millimetre : derived_unit {}; + struct square_millimetre : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; - struct square_centimetre : derived_unit {}; + struct square_centimetre : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; - struct square_metre : derived_unit {}; + struct square_metre : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; - struct square_kilometre : derived_unit {}; + struct square_kilometre : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; - struct square_foot : derived_unit {}; + struct square_foot : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/capacitance.h b/src/include/units/dimensions/capacitance.h index db3b3b00..88de5bcb 100644 --- a/src/include/units/dimensions/capacitance.h +++ b/src/include/units/dimensions/capacitance.h @@ -28,13 +28,13 @@ namespace std::experimental::units { - struct dimension_capacitance : make_dimension_t, exp, exp, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct capacitance : make_dimension_t, exp, exp, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Capacitance = Quantity && std::Same; + concept bool Capacitance = Quantity && std::Same; - struct farad : derived_unit {}; + struct farad : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/current.h b/src/include/units/dimensions/current.h index e8054cea..d7febc40 100644 --- a/src/include/units/dimensions/current.h +++ b/src/include/units/dimensions/current.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_current : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct current : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Current = Quantity && std::Same; + concept bool Current = Quantity && std::Same; - struct ampere : unit {}; + struct ampere : unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/electric_charge.h b/src/include/units/dimensions/electric_charge.h index 1f84ac79..9ab449c5 100644 --- a/src/include/units/dimensions/electric_charge.h +++ b/src/include/units/dimensions/electric_charge.h @@ -28,13 +28,13 @@ namespace std::experimental::units { - struct dimension_electric_charge : make_dimension_t, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct electric_charge : make_dimension_t, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool ElectricCharge = Quantity && std::Same; + concept bool ElectricCharge = Quantity && std::Same; - struct coulomb : derived_unit {}; + struct coulomb : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/energy.h b/src/include/units/dimensions/energy.h index 89114dc7..124d647f 100644 --- a/src/include/units/dimensions/energy.h +++ b/src/include/units/dimensions/energy.h @@ -28,13 +28,13 @@ namespace std::experimental::units { - struct dimension_energy : make_dimension_t, exp, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct energy : make_dimension_t, exp, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Energy = Quantity && std::Same; + concept bool Energy = Quantity && std::Same; - struct joule : derived_unit {}; + struct joule : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/force.h b/src/include/units/dimensions/force.h index a0162efd..0f351952 100644 --- a/src/include/units/dimensions/force.h +++ b/src/include/units/dimensions/force.h @@ -29,13 +29,13 @@ namespace std::experimental::units { - struct dimension_force : make_dimension_t, exp, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct force : make_dimension_t, exp, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Force = Quantity && std::Same; + concept bool Force = Quantity && std::Same; - struct newton : derived_unit {}; + struct newton : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/frequency.h b/src/include/units/dimensions/frequency.h index cfcad63d..af33d5ae 100644 --- a/src/include/units/dimensions/frequency.h +++ b/src/include/units/dimensions/frequency.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_frequency : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct frequency : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Frequency = Quantity && std::Same; + concept bool Frequency = Quantity && std::Same; - struct hertz : derived_unit {}; + struct hertz : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; struct millihertz : milli {}; diff --git a/src/include/units/dimensions/length.h b/src/include/units/dimensions/length.h index 3879e750..e3fca7b7 100644 --- a/src/include/units/dimensions/length.h +++ b/src/include/units/dimensions/length.h @@ -27,14 +27,14 @@ namespace std::experimental::units { - struct dimension_length : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct length : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Length = Quantity && std::Same; + concept bool Length = Quantity && std::Same; // SI units - struct metre : unit {}; + struct metre : unit {}; template<> struct downcasting_traits> : downcast_to {}; struct millimetre : milli {}; @@ -67,16 +67,16 @@ namespace std::experimental::units { } // namespace literals // US customary units - struct yard : unit> {}; + struct yard : unit> {}; template<> struct downcasting_traits> : downcast_to {}; - struct foot : unit, yard::ratio>> {}; + struct foot : unit, yard::ratio>> {}; template<> struct downcasting_traits> : downcast_to {}; - struct inch : unit, foot::ratio>> {}; + struct inch : unit, foot::ratio>> {}; template<> struct downcasting_traits> : downcast_to {}; - struct mile : unit, yard::ratio>> {}; + struct mile : unit, yard::ratio>> {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/luminous_intensity.h b/src/include/units/dimensions/luminous_intensity.h index 583e7888..927f3077 100644 --- a/src/include/units/dimensions/luminous_intensity.h +++ b/src/include/units/dimensions/luminous_intensity.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_luminous_intensity : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct luminous_intensity : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool LuminousIntensity = Quantity && std::Same; + concept bool LuminousIntensity = Quantity && std::Same; - struct candela : unit {}; + struct candela : unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/mass.h b/src/include/units/dimensions/mass.h index cc0db2b3..2e1b1d36 100644 --- a/src/include/units/dimensions/mass.h +++ b/src/include/units/dimensions/mass.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_mass : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct mass : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Mass = Quantity && std::Same; + concept bool Mass = Quantity && std::Same; - struct gram : unit> {}; + struct gram : unit> {}; template<> struct downcasting_traits> : downcast_to {}; struct kilogram : kilo {}; diff --git a/src/include/units/dimensions/power.h b/src/include/units/dimensions/power.h index ad4aee0d..06ba610d 100644 --- a/src/include/units/dimensions/power.h +++ b/src/include/units/dimensions/power.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_power : make_dimension_t, exp, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct power : make_dimension_t, exp, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Power = Quantity && std::Same; + concept bool Power = Quantity && std::Same; - struct watt : derived_unit {}; + struct watt : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/pressure.h b/src/include/units/dimensions/pressure.h index 6b8e655a..e390b95f 100644 --- a/src/include/units/dimensions/pressure.h +++ b/src/include/units/dimensions/pressure.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_pressure : make_dimension_t, exp, exp> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct pressure : make_dimension_t, exp, exp> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Pressure = Quantity && std::Same; + concept bool Pressure = Quantity && std::Same; - struct pascal : derived_unit {}; + struct pascal : derived_unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/substance.h b/src/include/units/dimensions/substance.h index 391f0409..2f522aae 100644 --- a/src/include/units/dimensions/substance.h +++ b/src/include/units/dimensions/substance.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_substance : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct substance : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool Substance = Quantity && std::Same; + concept bool Substance = Quantity && std::Same; - struct mole : unit {}; + struct mole : unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/temperature.h b/src/include/units/dimensions/temperature.h index 19d5ded8..de1540ae 100644 --- a/src/include/units/dimensions/temperature.h +++ b/src/include/units/dimensions/temperature.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_temperature : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct temperature : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to {}; template - concept bool ThermodynamicTemperature = Quantity && std::Same; + concept bool ThermodynamicTemperature = Quantity && std::Same; - struct kelvin : unit {}; + struct kelvin : unit {}; template<> struct downcasting_traits> : downcast_to {}; inline namespace literals { diff --git a/src/include/units/dimensions/time.h b/src/include/units/dimensions/time.h index 1f9813ed..4554a50c 100644 --- a/src/include/units/dimensions/time.h +++ b/src/include/units/dimensions/time.h @@ -27,13 +27,13 @@ namespace std::experimental::units { - struct dimension_time : make_dimension_t> {}; - template<> struct downcasting_traits> : downcast_to {}; + struct time : make_dimension_t> {}; + template<> struct downcasting_traits> : downcast_to