Boost logo

Boost :

Subject: [boost] [boost-users][ICL] ICL Compilation errors. Ticket #5207
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-02-21 15:22:32


Hi John, lists,

I am replying to your ticket #5207 on the lists because I am afraid
that you walked into a trap that others can fall into as well.

In the ITL, the precursor of Boost.ICL there was a single polymorphic
interval class template: itl::interval. Due to input from the list
during the review I split up this "one size fit's all" template in
smaller classes according to static and dynamic interval concepts.

In order to help ITL users to have a simple transition from ITL to ICL
I wrote a template icl::interval. icl::interval is a meta function
that yields the right interval type dependent on the instance type
e.g. :

BOOST_STATIC_ASSERT((
    boost::is_same< interval<int>::type
                  , discrete_interval<int> >::value
                  ));

So ITL users could move from ITL to ICL just by appending a '::type'
to all occurrences of 'interval<T>'

So please note that

interval<myType> myInterval;

can not be used as an interval type in ICL functions.

Please use
interval<myType>::type myInterval;

or one of the specific interval types

discrete_interval, continuous_interval, (dynamic borders)
closed_interval, right_open_interval,
left_open_interval, open_interval (static borders)

e.g.
discrete_interval<int> myInterval;

See examples
http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/interval.html
http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/dynamic_interval.html
http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/static_interval.html

and docs
http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/interface.html#boost_icl.interface.class_templates

for more detail.

This reduces John's non compilable ICL statements in the following way:

BOOST_AUTO_TEST_CASE(ticket_5207)
{
  icl::interval< int >::type int_interval;
  icl::interval_set< int > int_set;
  icl::interval_map< int, int > int_map;
  icl::interval_map< int, int >::element_type int_element;
  icl::interval_map< int, int >::segment_type int_segment;

  // The next 4 lines compile
  icl::lower( int_interval );
  icl::upper( int_interval );
  icl::first( int_interval );
  icl::last( int_interval );

  // The next 4 lines are *not* supposed to compile
  // according to the docs:
  icl::add( int_set, int_set );
  icl::add( int_map, int_map );
  icl::subtract( int_set, int_set );
  icl::subtract( int_map, int_map );

  int_set += int_interval; // compiles

  // Here you are right, John:
  // The next 4 lines should compile according
  // to the docs, but don't
  icl::disjoint( int_map, int_element );
  icl::disjoint( int_map, int_segment );
  icl::intersects( int_map, int_segment );
  icl::intersects( int_map, int_element );
  // Those four are pretty special. I doubt anyone will
  // use them. But I will complete the library here.
}

Thanks for using my library and helping to improve it.
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