Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-03-26 18:53:37


AMDG

Matthias Schabel <boost <at> schabel-family.org> writes:

>
> > - Please don't call the units used in the U.S. "English" units.
> > Here in England, we use the S.I. system for everything except pints
> > of beer and miles on roadsigns. The units that we did use here
> > until about 50 years ago were not the same as the ones that the
> > Americans use.
>
> In boost/units/systems/other/non_si_units.hpp I have included
> conversion factors for Imperial units (the ones used in the recent
> past in England), US Customary units, US Survey units, nautical
> units, some non-SI metric units, etc... English units generally refer
> to heterogeneous and obsolete units, while Imperial and US Customary
> are the main non-SI systems still in some use... See here, also :
>
> http://en.wikipedia.org/wiki/English_unit
>

We could define the base units separately
and then mix and match

struct meter_tag : public ordinal<1> {};
struct foot_tag : public ordinal<2> {};
struct inch_tag : public ordinal<3> {};
struct yard_tag : public ordinal<4> {};
struct mile_tag : public ordinal<5> {};

struct gram_tag : public ordinal<6> {};
struct slug_tag : public ordinal<7> {};

struct second_tag : public ordinal<8> {};
struct minute_tag : public ordinal<9> {};
struct hour_tag : public ordinal<10> {};

struct ampere_tag : public ordinal<11> {};
struct biot_tag : public ordinal<12> {};

struct kelvin_tag : public ordinal<13> {};

struct mole_tag : public ordinal<14> {};

struct candela_tag : public ordinal<15> {};

struct radian_tag : public ordinal<16> {};
struct degree_tag : public ordinal<17> {};
struct gradian_tag : public ordinal<18> {};

struct steradian_tag : public ordinal<19> {};

// specializations of base_unit_converter and
// unit_info

namespace SI {
  typedef make_system<
    mpl::map<
      mpl::pair<length_tag, meter_tag>,
      mpl::pair<mass_tag, scaled_system<gram_tag, 1000> >,
      mpl::pair<time_tag, second_tag>,
      mpl::pair<current_tag, ampere_tag>,
      mpl::pair<temperature_tag, kelvin_tag>,
      mpl::pair<amount_tag, mole_tag>,
      mpl::pair<intensity_tag, candela_tag>,
      mpl::pair<angle_tag, radian_tag>,
>
>::type system_tag;
}

Everything else in si/* remains the same
make_system and scaled_system each
take about 50 lines of code to implement.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk