|
Boost Users : |
Subject: Re: [Boost-users] [boost][boost-users][ICL] ICL Compilation errors. Ticket #5207
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-02-22 15:03:29
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.
interval_map::find is a pretty late addition to ITL/ICL, because using
find in the STL way makes little sense on interval containers most of
the time. We can not "find" an large interval in an icl::interval_set
of small intervals.
{[0,2),[5,7)}.find([0,9))
The generalization of find is intersection. And the following function
calls compile for statically bounded right-open intervals of
continuous types:
#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
#include <boost/icl/interval_map.hpp>
{
icl::interval_map< float, int> iclmap;
icl::interval_map< float, int> found;
add_intersection(found, iclmap,
right_open_interval<float>(0,1));
add_intersection(found, icl::interval_map< float, int>(),
right_open_interval<float>(0,1));
found = iclmap & right_open_interval<float>(0,1);
found = icl::interval_map< float, int>()
& right_open_interval<float>(0,1);
}
> This makes me think it might be worth having tests for
> every possible combination that is listed in the function
> synopsis for both static and for dynamic intervals:
> http://www.boost.org/doc/libs/1_46_0/libs/icl/doc/html/boost_icl/interface/function_synopsis.html
I am working on it. But as you see from this example, not every
function overload works for dynamically bounded and statically bounded
intervals in the same way. I think the documentation can be improved
here.
> I can keep you up-to-date with any further problems I find
please do.
> but I'm just wondering whether it would be easier to fix them all in one go.
Currently it's no problem for me to fix them as they are detected.
Cheers,
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