|
Boost Users : |
Subject: Re: [Boost-users] [Units] Name a unit for output
From: Santiago Ospina (sospinar_at_[hidden])
Date: 2017-12-20 10:03:09
> On 20. Dec 2017, at 05:04, Steven Watanabe via Boost-users <boost-users_at_[hidden]> wrote:
>
> AMDG
>
> On 12/19/2017 05:38 PM, Santiago Ospina via Boost-users wrote:
>> 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?
>>
>
> try:
> #include <boost/units/base_units/metric/minute.hpp>
> using minutes = boost::units::metric::minute_base_unit::unit_type;
>
> You should be able to use the same method of specializing
> base_unit_info.
>
Please notice minute was just a very dumb example to illustrate the idea.
Santiago
> In Christ,
> Steven Watanabe
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
> https://lists.boost.org/mailman/listinfo.cgi/boost-users <https://lists.boost.org/mailman/listinfo.cgi/boost-users>
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