Closed bladan closed 4 years ago
Would love to do that, but the C++ user defined literals do not allow for a /
in the literal as it is a reserved character.
However in that case I would use something like this:
template <typename _type> using km_per_hour_t = velocity_t<_type, std::ratio<1000/3600>>;
constexpr km_per_hour<double> SPEED_CONSTANT{10.0};
I'm considereing adding km_per_h_t
and similar often used unit-types in a future release.
Something like km_per_h_t
would be a good solution.
Defining constants of derived data types could be more intiutive, as we have to always give a number before a literal: auto SPEED_CONSTANT = 10_km / 1_h;
How about allowing the line below or similar: auto SPEED_CONSTANT = 10_km/h;