|
Boost Users : |
Subject: Re: [Boost-users] [math][tools][units] generic libraries not genericenough
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-08-26 05:55:13
Hi again,
Just to be fair, I have to add that boost.units needs a small set of
additions in order to make easier and encourage other libraries to be
generic. At least two:
1) division and multiplication by integer
currently this fails to compile
mid = (min + max)/2; // fails
because 2 is an integer.
2) comparison with "symbolic" 0, i.e. null,
for consistency with zero constructor. Currently
boost::quantity<si::length> a(0); // ok currently
if(a==0) ...; //not ok currently, workaround if(a == quantity<...>(0))
if(a > 0) ...; //not ok currently, workaround if(a > quantity<...>(0))
a = 0; //not ok currently
these two operation are very common in math applications (like root finding
:) ).
I have an implementation of 1) and 2) of my own (except operator= which is
not possible to have a non member function),
I think if these very basic things are incorporated in boost.units then
libraries with boost.units in mind will be easier to develop.
Alfredo
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