Boost logo

Boost Users :

Subject: [Boost-users] [Units] Name a unit for output
From: Santiago Ospina (sospinar_at_[hidden])
Date: 2017-12-20 00:38:06


Hello boost-users,

I would like to know if there is an equivalent for giving a name and a symbol given a unit in boost::units (maybe scaled from another one).

I know the example of naming base units, however, it would imply I'd have to create a system and a conversion for every unit I want to implement.

I tried to write it directly from the scaled version, like this:

  template<>
  struct scale_minute<60, static_rational<1> >
  {
      static const long base = 60;
      typedef Detail::static_rational<1> exponent;
      typedef double value_type;
      static value_type value() { return(60); }
      static std::string name() { return("minute"); }
      static std::string symbol() { return("m"); }
  };

however, it is adding my scaled name plus my base name (say the base name is “s” which stands for seconds, then it would print “m” + "s”).

Any idea how to overcome with that?


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