|
Boost : |
Subject: Re: [boost] [review][constrained_value] ReviewofConstrainedValueLibrary begins today
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-12-06 03:19:58
----- Original Message -----
From: "Robert Kawulak" <robert.kawulak_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, December 06, 2008 4:31 AM
Subject: Re: [boost] [review][constrained_value] ReviewofConstrainedValueLibrary begins today
>
>> From: vicente.botet
>
>> >> I would prefer
>> >> to have two separated hierarchies, one for constrained values
>> >> that preserv its constraints, error handling, ... staticaly,
>> >> and one for those tyhe constraint can be changed at runtime.
>> >
>> > I wouldn't prefer to have two separate hierarchies with
>> almost identical
>> > functionality and differing only in details.
>>
>> Well we can have a single type that cover with the whole
>> domain, but we will need more metaprogramming.
>
> We already have a single type that covers both static and dynamic constraints,
> so what is the point? Did I misunderstood something?
I'm sorry. I didn't see that you provide already static constraints. >From the documentation it was not clear to me that with your library you can do
bounded<int>::type dyn_v;
change_lower_bound(v, -5);
but not
bounded_int<int, 0, 128>::type _v;
change_lower_bound(v, -5); // do not compiles
I supose that I've missed the difference between 'bounded_int' and 'bounded<int>' and that I have skipped this sentence in the documentation:
"The trick is to "convert" a value into a type, i.e. create a type that can be converted to the desired type yielding the value"
It would be great if the documentation state explicitly that
change_lower_bound(v, -5);
do not compiles for bounded_int. And why not find a better name for bounded_int.
>> I expect that a constrained integer will have the same size
>> as an int, i.e. sizeof(int). Which is the size of an instance
>> of the constrained class?
>
> Here are some examples:
>
> GCC 4.3.2:
>
> 4 = sizeof (int)
> 4 = sizeof (bounded_int<int, 0, 128>::type)
> 12 = sizeof (bounded<int, int, int>::type)
> 4 = sizeof (constrained<int, is_even>)
>
> MSVC 8.0 SP1:
>
> 4 = sizeof (int)
> 8 = sizeof (bounded_int<int, 0, 128>::type)
> 20 = sizeof (bounded<int, int, int>::type)
> 8 = sizeof (constrained<int, is_even>)
>
> I don't know why MSVC cannot opimise the size as well as GCC, but anyway the
> library allows for perfect size optimisation with some compilers.
I hope you will find how to solve this issue.
This is exaclty what I was locking for, but it was no evident to me your library provided it already
I see now that this is really a well designed library.
Thanks,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk