|
Boost : |
Subject: Re: [boost] [Boost-users] [boost-users][ICL] ICL Compilation errors. Ticket #5207
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-02-24 09:20:04
(4) Using statically and dynamically bounded intervals in the same
compilation unit.
2011/2/23 John Reid <j.reid_at_[hidden]>:
> On a side note, I don't understand the rationale for having static bounds
> configured by #define whilst other aspects of intervals are parameterised
> using templates.
You can always instantiate ICL interval container templates with the
interval type of your choice via the template parameter IntervalT. See
e.g.
http://www.boost.org/doc/libs/1_46_0/libs/icl/doc/html/boost_icl/interface.html#boost_icl.interface.class_templates.sets
#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
switches the default value for this template-parameter from
dynamically bounded to statically bounded intervals. Like any other
default of a template parameter you can change it via instantiation.
The rational behind this is
(1) the intention, to minimize the effort for users, that have
applications of ITL containers and want to change their code using
statically bounded intervals now. In the ITL every interval was
dynamically bounded.
(2) for applications that only use one kind of intervals, e.g.
statically bounded ones, #define
BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS can be convenient, because you
need only to specify the first one or two template parameter for
interval containers most of the time.
> I would have liked to have both types of interval in the
> same compilation unit.
NP
> However I guess it must be too late to change this
> fundamental design choice.
Fortunately it's not too late ;-)
This code shows how to use icl sets with variations of interval types.
BOOST_AUTO_TEST_CASE(using_vaious_interval_types)
{
interval_set<int, std::less, discrete_interval<int,std::less> > dyn_int_set;
interval_set<int, std::less, right_open_interval<int,std::less> >
stat_int_set;
interval_set<float, std::less, continuous_interval<float,std::less>
> dyn_float_set;
dyn_int_set += discrete_interval<int>(1);
BOOST_CHECK(( contains(dyn_int_set,1) ));
stat_int_set += right_open_interval<int>(1);
BOOST_CHECK(( contains(stat_int_set,1) ));
dyn_float_set += continuous_interval<float>(1.0);
BOOST_CHECK(( contains(dyn_float_set, 1.0) ));
}
For interval_map this can get a little verbose, because of the greater
number of template parameters.
Thank you for your questions. They help to clarify a lot of issues
around the library (even for the author:)
Joachim
-- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk