Boost logo

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


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.

> 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.

  interval_set<int, std::less, discrete_interval<int,std::less> > dyn_int_set;
  interval_set<int, std::less, right_open_interval<int,std::less> >
  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:)


Interval Container Library [Boost.Icl]

Boost list run by bdawes at, gregod at, cpdaniel at, john at