[units] easier "power" of units generation
Hi, I have a custom units, for example, angstrom: typedef scaled_base_unit<si::meter_base_unit, scale<10, static_rational<-10> > > angstrom_base_unit; typedef metric::angstrom_base_unit::unit_type angstrom_unit; static const angstrom_unit angstrom; and I have a quantity quantity<angstrom_unit> L=1.*angstrom; and I want to have a variable that has dimensions of volume and angstrom^3 units: ??? V = pow<3>(L); ¿how can I generate the type of V, given angstrom_unit? I found this complicated way: quantity<unit< volume_dimension, make_system<angstrom_base_unit>::type
V = pow<3>(L);
Is there a more compact way or a way that doesn't explicitly mention angstrom_base_unit?, something like quantity<static_power<angstrom_unit, 3>::unit> V = pow<3>(L); // not working In other words, what are the metafunctions necessary to generate the typeof(pow<3>(L)) from angstrom_unit. Thank you, Alfredo
AMDG alfC wrote:
I have a custom units, for example, angstrom:
typedef scaled_base_unit<si::meter_base_unit, scale<10, static_rational<-10> > > angstrom_base_unit; typedef metric::angstrom_base_unit::unit_type angstrom_unit; static const angstrom_unit angstrom;
and I have a quantity
quantity<angstrom_unit> L=1.*angstrom;
and I want to have a variable that has dimensions of volume and angstrom^3 units:
??? V = pow<3>(L);
¿how can I generate the type of V, given angstrom_unit?
The metafunction is power_typeof_helper. quantity<power_typeof_helper<angstrom_unit, static_rational<3> >::type> V; In Christ, Steven Watanabe
On May 6, 7:48 am, Steven Watanabe <watanab...@gmail.com> wrote:
The metafunction is power_typeof_helper. quantity<power_typeof_helper<angstrom_unit, static_rational<3> >::type> V;
Thank you, at least it is more explicit in it meaning. This also seems to work for some magical reason (your magic probably): power_typeof_helper<quantity<angstrom_unit>, static_rational<3>
::type V2;
Thank you, Alfredo
participants (2)
-
alfC
-
Steven Watanabe