Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Dimensionless? expecting length+length
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2015-08-10 23:30:21

On Mon, Aug 10, 2015 at 10:50 PM, Gavin Lambert <gavinl_at_[hidden]> wrote:
> On 11/08/2015 14:12, Michael wrote:
>>> You can, but it's not necessary. Simply assign value * milli * seconds
>>> to a variable of quantity<time> (aka Time) and it automatically
>>> converts
>>> everything to seconds (since that's the base unit of "time"). This
>>> prevents other operations getting confused by scaled units, which
>>> happens when you use "auto" because it skips this conversion.
>> Ah I gotcha. So the prevailing wisdom is auto auto auto, except when
>> quantities and prefixed unit conversions are concerned.
> I'm not sure about "prevailing wisdom". I don't use auto anywhere with
> Boost.Units (I use explicit types as mentioned above instead). But then,
> most of my usage of Boost.Units was written in the dark ages (C++03
> compiler).
> TBH your code seems a little too auto-happy to me -- I wouldn't have defined
> things like "two" or "milliseconds" or "gValue" or the static_casts and
> would have just written the values inline instead, as I think it's
> sufficiently clear that way. But that's just a coding style thing (the
> compiler should be smart enough to generate the same code either way) and if
> you think that makes it clearer for you then go for it. That's probably a
> more reasonable place to use "auto", for things that aren't quantities.

No problem. Thanks for the critique anyhow. It's an early prototype,
just pulling some concepts together. I'll likely rewrite it 2-3 times
anyway, before it's all said and done. I'm already capturing
"calculator" concerns such as "e" and "g" as true-quantity constants
in a calculator structure, for example. I'm finding that helps add
clarity to the code, as well. Still, I like auto when it makes sense;
kind of like C# var.

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at