Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-08-26 08:03:13


"Matthias Troyer" <troyer_at_[hidden]> wrote in message
news:2F9215A5-A36E-4139-A289-E0E6C095AEC5_at_itp.phys.ethz.ch...
>
> On Aug 23, 2006, at 8:50 PM, Andy Little wrote:
>
>>
>> This is merely because the use cases are potentially pretty wide.
>> In the review
>> I made it clear that I was limiting the scope of Quan to the SI
>> unit system,
>> because that is the one I understand. If I resubmitted the library
>> it could be
>> rejected as not being generic enough and there are inklings from
>> this thread
>> that this may be the reaction. But I don't have the time or the
>> knowledge to
>> write a truly generic physical quantities library and if that is
>> the requirement
>> then there isnt much point in resubmitting Quan for another review
>> AFAICS.
>
> Can the dimension checking part of the library be used without the SI
> unit system? For most other unit systems I use, I mainly need
> dimension checking and not conversions between different units, such
> as km or m? Thus just a quantity with dimensions would be useful to
> catch programming errors.

Yes. In the signature fixed_quantity<Unit, ValueType>, the Unit parameter can
be so modelled that it only allows base units to be used, and in this case there
is no conversion overhead BTW, a multiply is simply a multiply of the numeric
values for example). By default Quan wont work across Unit models (IOW the
class template names of units must match), which means that attempting to do
calculations between Units with different class template names will fail at
compile time. By this means you can guarantee that you can prevent any
conversions. (FWIW there is also the option to allow unit conversions but make
them explicit, prompted by Deane Yang easrlier in this thread.)

As yet this only applies easily to the CVS version of Quan, but I hope that we
will be able to get another release out shortly, which reflects what is
currently in the CVS version. I will hopefully announce it boost.devel once the
next release is available.

regards
Andy Little


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