Boost logo

Boost :

Subject: Re: [boost] [constrained_value] Constrained Value review results
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-10-17 15:36:43


----- Original Message -----
From: "Robert Kawulak" <robert.kawulak_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, October 17, 2010 3:29 AM
Subject: Re: [boost] [constrained_value] Constrained Value review results

> In general, the idea looks interesting and also consistent with the idea of Vicente Botet to specify bounds inclusion like this:
>
> bounded<int, open_c<0>, close_c<100> >
>

> This would allow to write:
>
> bounded<int, bound::int_c<-10>, bound::int_c<10> >
> bounded<int, bound::of_type<int>, bound::of_type<int> >
> bounded<rational, bound::of_type<quarter2type>, bound::of_type<half2type> >
> bounded<int, bound::int_c<0>, bound::of_type<big_prime> >
> bounded<int, bound::int_c<0, bound::included>, bound::of_type<int, bound::excluded> >
>
> Being more explicit it is also unfortunately more verbose in most cases, compared to the current syntax:
>
> bounded_int<int, -10, 10>
> bounded<int>
> bounded<rational, quarter2type, half2type>
> bounded<int, mpl::int_<0>, big_prime>
> bounded<int, mpl::int_<0>, int, throw_exception<>, mpl::false_, mpl::true_>

I was wondering whether the library could not define some more generic logical and comparison constraints so we can do

constrained<int, and_<greater_equal<int_<-10> >, less_equal<int_<10> > > >
constrained<int, and_<greater_equal<ratio<1,4> >, less_equal<ratio<1,2> > > >
constrained<int, and_<greater_equal<int_<0> >, less_equal<big_prime > > >
constrained<int, and_<greater<int_<0> >, less_equal<int_<10> > > >

This will cover all the bounded cases with inclusion or exclusion of the bound.

Best,
Vicente


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