Boost logo

Boost Users :

Subject: [Boost-users] [units] easier "power" of units generation
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-05-06 01:21:49


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net