|
Boost Users : |
Subject: Re: [Boost-users] [boost][boost-users][ICL] ICL Compilation errors. Ticket #5207
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-02-24 05:48:28
Hi John,
thanks again for all the questions. I am breaking up the long posting
into smaller portions.
(1) Representation of single elements with statically bounded intervals:
2011/2/23 John Reid <j.reid_at_[hidden]>:
> On 22/02/11 20:03, Joachim Faulhaber wrote:
>>
>> 2011/2/22 John Reid<j.reid_at_[hidden]>
>>>
>>> I have started to use statically bounded intervals
>>> and am finding more compilation issues. For example
>>> with finding elements in a map:
>>>
>>> #define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
>>> #include<boost/icl/interval_map.hpp>
>>>
>>> void f() {
>>> namespace icl = ::boost::icl;
>>> icl::interval_map< float, int>().find( 0 );
>>> }
>>>
>>> This compiles without the #define but fails on static intervals.
>>
>> This is on purpose. The reason is that we can not represent a single
>> element x using a right-open interval [x,?) of continuous values.
>> right_open_interval is the default for statically bounded intervals,
>> if BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS is defined. In order to use
>> find on an interval_map we have to construct an interval that
>> represents a single element (internally). This is not possible in the
>> logic of the ICL so this code won't compile.
>
> Nevertheless, users will expect to be able to locate elements in sets. How
> should they do this?
they could use dynamically bounded intervals for continuous interval
element types :P
Moreover, if we work with floating point numbers, the code
float pi = 3.14159 ... ;
icl::interval_set<float> icl_float_set = ... ;
icl::contains( icl_float_set, pi );
would be problematic anyway since pi can not be represented precisely.
right_open_interval<float> pi_itv = interval_around_pi();
icl::contains( icl_float_set, interval_around_pi() ); // better
> Does
> icl::contains( icl::interval_set< int >(), 0 );
> compile, but
> icl::contains( icl::interval_set< float >(), 0. );
> does not for the same reason?
yes.
I have mentioned in the docs, that 'continuous_interval' is the only
class template that allows to represent a singleton interval that
contains only one element, an have provided a small example here:
Regards,
Joachim
-- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
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