|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2004-05-22 12:37:41
On 5/16/04 11:09 AM, "christopher diggins" <cdiggins_at_[hidden]> wrote:
[SNIP]
> template<typename T, T min_T, T max_T>
> struct integer_range_policy
> {
> typedef typename T value;
> static const value min() { return min_T; };
> static const value max() { return max_T; };
> };
[SNIP]
> template
> <
> class constraints_policy,
> class error_policy = default_error_policy,
> bool implicit_conversion_policy = true
> >
> class constrained_value {
> private:
> struct unused_struct { };
> public:
> typedef constrained_value<constraints_policy, error_policy,
> implicit_conversion_policy> self;
> typedef typename constraints_policy::value value;
> typedef typename mpl::if_c<implicit_conversion_policy, value,
> unused_struct> value_parameter;
> constrained_value() : m(min()) { }
> constrained_value(const self& x) { m = x.get_value(); }
> constrained_value(value_parameter x) { assign(x); }
> static const value min() { return constraints_policy::min(); }
> static const value max() { return constraints_policy::max(); }
> const value get_value() const { return m; }
> operator value() { return m; }
> self& operator=(const self& x) { m = x; return *this; }
> self& operator=(value_parameter x) { assign(x); return *this; }
> void assign(unused_struct x) { }
> void assign(const value& x)
> {
> #ifdef BOOST_CV_CHECKING_ON
> {
> // +1 removes unsigned warnings
> if (x+1 < min()+1) {
> error_policy::on_error(x, &m, min(), max(),
> policies::min_violation);
> return;
> }
> if (x > max()) {
> error_policy::on_error(x, &m, min(), max(),
> policies::max_violation);
> return;
> }
> }
> #endif
> m = x;
> }
> private:
> value m;
> };
> };
> };
Should those "value" types be more like "value_type" to reduce confusion on
what that member is?
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk