change const order

move in,ft,fathom,ft2,ft3,mph from us to international namespace
TODO distinguish units with different names for same values
This commit is contained in:
Andy Little
2020-01-12 21:34:36 +01:00
committed by Mateusz Pusz
parent c93136e81b
commit 024f5a9c83
15 changed files with 109 additions and 58 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
#include <units/physical/cgs/velocity.h>
#include <units/physical/si/velocity.h>
#include <units/physical/us/velocity.h>
#include <units/physical/international/velocity.h>
#include <iostream>
namespace {
+8 -8
View File
@@ -56,26 +56,26 @@ namespace{
struct Box{
Box(length::m<> const& l,
length::m<> const& w,
length::m<> const& h
Box(const length::m<> & l,
const length::m<> & w,
const length::m<> & h
): length{l},width{w},height{h}{}
force::N<> filled_weight()const
{
volume::m3<> const volume
const volume::m3<> volume
= length * width * height;
mass::kg<> const mass = contents.density * volume;
const mass::kg<> mass = contents.density * volume;
return mass * acceleration::g<>;
}
length::m<> fill_level(mass::kg<> const & measured_mass)const
length::m<> fill_level(const mass::kg<> & measured_mass)const
{
return height
* (measured_mass * acceleration::g<>) / filled_weight();
}
volume::m3<> spare_capacity(mass::kg<> const & measured_mass)const
volume::m3<> spare_capacity(const mass::kg<> & measured_mass)const
{
return (height - fill_level(measured_mass)) * width * length;
}
@@ -85,7 +85,7 @@ struct Box{
density::kgpm3<> density;
}contents;
void set_contents_density(density::kgpm3<> const & density_in)
void set_contents_density(const density::kgpm3<> & density_in)
{
assert( density_in > air_density );
contents.density = density_in;
+4 -4
View File
@@ -56,13 +56,13 @@ int main()
std::cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
std::cout.precision(3);
auto constexpr C = 0.47uF;
auto constexpr V0 = 5.0V;
auto constexpr R = 4.7kR;
constexpr auto C = 0.47uF;
constexpr auto V0 = 5.0V;
constexpr auto R = 4.7kR;
for ( auto t = 0ms ; t <= 50ms; ++t ){
auto const Vt = V0 * std::exp(-t / (R * C));
const auto Vt = V0 * std::exp(-t / (R * C));
std::cout << "at " << t << " voltage is " ;
+12 -12
View File
@@ -128,12 +128,13 @@ void simple_quantities()
{
using distance = length::m<>;
using time = time::s<>;
distance constexpr km = 1.0km;
distance constexpr miles = 1.0mi;
time constexpr sec = 1s;
time constexpr min = 1min;
time constexpr hr = 1h;
constexpr distance km = 1.0km;
constexpr distance miles = 1.0mi;
constexpr time sec = 1s;
constexpr time min = 1min;
constexpr time hr = 1h;
std::cout << "A physical quantities library can choose the simple\n";
std::cout << "option to provide output using a single type for each base unit:\n\n";
@@ -146,15 +147,14 @@ void simple_quantities()
void quantities_with_typed_units()
{
length::km<> constexpr km = 1km;
length::mi<> constexpr miles = 1.0mi;
constexpr length::km<> km = 1km;
constexpr length::mi<> miles = 1.0mi;
std::cout.precision(6);
time::s<> constexpr sec = 1s;
time::min<> constexpr min = 1min;
time::h<> constexpr hr = 1h;
constexpr time::s<> sec = 1s;
constexpr time::min<> min = 1min;
constexpr time::h<> hr = 1h;
std::cout << "A more flexible option is to provide separate types for each unit,\n\n";
std::cout << km << '\n';
@@ -163,7 +163,7 @@ void quantities_with_typed_units()
std::cout << min << '\n';
std::cout << hr << "\n\n";
length::m<> constexpr meter = 1m;
constexpr length::m<> meter = 1m;
std::cout << "then a wide range of pre-defined units can be defined and converted,\n"
" for consistency and repeatability across applications:\n\n";
+3 -3
View File
@@ -48,7 +48,7 @@ namespace {
}
// get at the units text of the quantity, without its numeric value
auto inline constexpr units_str( units::Quantity const & q)
auto inline constexpr units_str( const units::Quantity & q)
{
typedef std::remove_cvref_t<decltype(q)> qtype;
return units::detail::unit_text<typename qtype::dimension, typename qtype::unit>();
@@ -74,8 +74,8 @@ int main()
{
std::cout << "conversion factor in mpusz/units...\n\n";
length::m<> constexpr lengthA = 2.0m;
length::mm<> constexpr lengthB = lengthA;
constexpr length::m<> lengthA = 2.0m;
constexpr length::mm<> lengthB = lengthA;
std::cout << "lengthA( " << lengthA << " ) and lengthB( " << lengthB << " )\n"
"represent the same length in different units.\n\n";
+1 -1
View File
@@ -21,7 +21,7 @@
// SOFTWARE.
#include <units/physical/si/velocity.h>
#include <units/physical/us/velocity.h>
#include <units/physical/international/velocity.h>
#include <units/format.h>
#include <iostream>