forked from mpusz/mp-units
Physical units put in the physical namespace (I am sorry)
This commit is contained in:
@@ -25,23 +25,24 @@
|
||||
|
||||
namespace {
|
||||
|
||||
template<units::Length D, units::Time T>
|
||||
constexpr units::Velocity AUTO avg_speed(D d, T t)
|
||||
template<units::physical::Length D, units::physical::Time T>
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user