Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost] [review][constrained_value] Review of ConstrainedValueLibrary begins today
From: jesseperla_at_[hidden]
Date: 2008-12-07 20:08:15


Robert:

>First, I hope that you are aware of the issues with using floating point
types
>with this library. If not, please read the rationale section of the
>documentation and the discussion in the related thread on the developers'
list.
Yup, been following. You did a good job of educating me on a previous
post... I think I understand the issue now, but don't really have much of
an option. As far as I can undestand from the discussions, this is a
general problem with equality operations with floating points and has
nothing to do with your library. If this is true, I would change
the "rationale" section to say that the mess is not your fault and it
isn'ta library problem and that you need to be just as careful as you would
normally.

>The constraint could look like this (written out of my head, not tested):
If this is possible, I am very happy. It looks like it is.
The only other things that I would say need to be thought through in the
design is unions of constraints instead of just intersections of them. For
example, I was checking this out a while back, and it manages the sets of
intervals/etc. well: http://www.herold-faulhaber.de/itl/
I would wonder if formalizing intervals in this library (or using another)
is a good way to deal with different bounds... but that is beyond my level
of competence.

> Why not just use numeric_limits<risk_aversion::value_type>?
1) Because I was too stupid to think of that, and
2) Because I want to be able to write generic functions such as:
template<typename T>
bool is_NaN(T& t)
{
return (t == std::numeric_limits< T >::quiet_NaN());
}

Again, my idea is that I want to be able to throw around elements of
constrained types to generic functions and all of the standard types of
things I would do with the superset type.

>Actually, only the mutating operators (++, --, =, += etc.) are overloaded.
For
>I don't think this is needed. If you write:
> constrained<int> x, y, z;
> z = x + y;
>Then simply the + operator for int is used.
Even better. As long as it works for all of the auto conversions between
intrinsic types we are also in business. eg
constrained<int> x, y, z;
double c;
z = c * x + y;

Thanks Robert. Great library, time for me to submit a glowing review.



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