Boost logo

Boost Users :

Subject: Re: [Boost-users] [review][constrained_value] Review of Constrained Value Library begins today
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2008-12-06 17:07:09


One idea on the dynamically changing the global bounds for a type as I keep
mentioning, one concern people have is that it could invalidate instantiated
objects of the type.
As I said before, being able to dynamically change the bounds at runtime is
essential, but most of the time you would do it before you instantiate
anything. Hence, one solution is to make a check to see if it has been
instantiated yet. I don't know enough metaprogramming to know if this is
possible, but the idea is to flip some kind of a compile time flag in the
constructor of the type and if you try to change the bounds after that, it
fails a compile time assertion.

So, the following would work:
typedef bounded_type<double, "INTEREST RATE"> interest_rate;
interest_rate::change_bounds(.8, .99);
interest_rate r = .95;

But the following would fail at compile time:
typedef bounded_type<double, "INTEREST RATE"> interest_rate;
interest_rate r = .95;
interest_rate::change_bounds(.8, .99);

If this is a good idea, my only request is a preprocessor instruction to
turn it off...

-Jesse



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