forked from mpusz/mp-units
deduced_unit fixed + unit test for mass unit added
This commit is contained in:
@@ -61,7 +61,8 @@ struct derived_ratio<exp_list<>, Us...> {
|
|||||||
template<typename E, typename... ERest, Unit U, Unit... URest>
|
template<typename E, typename... ERest, Unit U, Unit... URest>
|
||||||
struct derived_ratio<exp_list<E, ERest...>, U, URest...> {
|
struct derived_ratio<exp_list<E, ERest...>, U, URest...> {
|
||||||
using rest_ratio = derived_ratio<exp_list<ERest...>, URest...>::ratio;
|
using rest_ratio = derived_ratio<exp_list<ERest...>, URest...>::ratio;
|
||||||
using ratio = ratio_op<rest_ratio, E::num, E::den, typename U::ratio>::ratio;
|
using unit_ratio = ratio_op<rest_ratio, E::num, E::den, typename U::ratio>::ratio;
|
||||||
|
using ratio = ratio_divide<unit_ratio, typename dimension_unit<typename E::dimension>::ratio>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<DerivedDimension D, Unit... Us>
|
template<DerivedDimension D, Unit... Us>
|
||||||
|
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
namespace units::si {
|
namespace units::si {
|
||||||
|
|
||||||
struct kilogram : named_unit<kilogram, "kg", no_prefix> {};
|
struct gram : named_unit<gram, "g", prefix> {};
|
||||||
struct gram : named_scaled_unit<gram, "g", prefix, ratio<1, 1'000>, kilogram> {};
|
struct kilogram : prefixed_unit<kilogram, kilo, gram> {};
|
||||||
struct tonne : named_scaled_unit<tonne, "t", prefix, ratio<1'000>, kilogram> {};
|
struct tonne : named_scaled_unit<tonne, "t", prefix, ratio<1'000>, kilogram> {};
|
||||||
|
|
||||||
struct dalton : named_scaled_unit<dalton, "Da", no_prefix, ratio<16'605'390'666'050, 10'000'000'000'000, -27>, kilogram> {};
|
struct dalton : named_scaled_unit<dalton, "Da", no_prefix, ratio<16'605'390'666'050, 10'000'000'000'000, -27>, kilogram> {};
|
||||||
|
@@ -20,7 +20,9 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
|
#include <units/physical/si/mass.h>
|
||||||
#include <units/physical/si/voltage.h>
|
#include <units/physical/si/voltage.h>
|
||||||
|
#include <units/physical/si/time.h>
|
||||||
#include <units/physical/si/frequency.h>
|
#include <units/physical/si/frequency.h>
|
||||||
#include <units/math.h>
|
#include <units/math.h>
|
||||||
|
|
||||||
@@ -54,3 +56,13 @@ static_assert(std::is_same_v<decltype(pow<2>(amplitude_spectral_density<volt_per
|
|||||||
static_assert(std::is_same_v<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
static_assert(std::is_same_v<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct kilogram_per_second : unit<kilogram_per_second> {};
|
||||||
|
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exp<si::dim_mass, 1>, units::exp<si::dim_time, -1>> {};
|
||||||
|
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, si::kilogram, si::hour> {};
|
||||||
|
constexpr auto a = 1kg / 1h;
|
||||||
|
static_assert(std::is_same_v<decltype(a)::unit, kilogram_per_hour>);
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user