Subject: Re: [boost] [units] Interest in UDLs (e.g. _kg) for units?
From: Marek Kurdej (curdeius_at_[hidden])
Date: 2014-08-25 12:31:16
> From: Mathias Gaunard <mathias.gaunard_at_[hidden]>
> To: boost_at_[hidden]
> Date: Mon, 25 Aug 2014 17:16:21 +0200
> Subject: Re: [boost] [units] Interest in UDLs (e.g. _kg) for units?
> On 25/08/14 16:03, Sebastian Redl wrote:
> > On 25 Aug 2014, at 13:24, Mathias Gaunard <mathias.gaunard_at_[hidden]>
> >> On 22/08/14 10:08, Curdeius Curdeius wrote:
> >>> Hi all,
> >>> I was wondering if there is any interest in adding User-Defined
> >>> (UDLs) to Boost.Units.
> >>> IMO, it could simplify some code and improve code readability in some
> >>> For example instead of writing (it's a somehow artificial example)
> >>> 5.34 * si::milli * si::kilogram;
> >>> 1234 * si::kilogram;
> >>> one would write
> >>> 5.34_g;
> >>> 1234_kg;
> >> Did you mean to write
> >> 5.34_g * si::milli;
> >> or
> >> 5.34_mg;
> >> ?
> > No, to get grams you need si::milli * si::kilogram. I assume the
> intention is that the _g suffix already includes that scaling - otherwise
> itâd be broken.
> Sorry, I read that too fast.
> In any case the idea would be to get suffixes that include all prefix
> variants as well.
Yes, the idea is to include all the prefix variants as well, so for the
mass, we will have:
..., _ng, _ug (?), _mg, _g, _kg, _Mg,_Gg, _Tg, ...
And, the fact is, writing si::milli * si::kilogram is counterintuitive as
you have just experienced on your own.
-- Ph.D. candidate