Opened 12 years ago

Closed 12 years ago

#5207 closed Bugs (fixed)

ICL compile errors

Reported by: John Reid <j.reid@…> Owned by: Joachim Faulhaber
Milestone: To Be Determined Component: ICL
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

See the code for some compilation problems. I haven't checked if there are other problems with continuous domains or static bounds.

#include <boost/icl/interval.hpp>
#include <boost/icl/interval_set.hpp>
#include <boost/icl/interval_map.hpp>
namespace icl = ::boost::icl;

void f() {
	icl::interval< int > 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;

	/// AFAICT none of the following lines compiles and they all should:
	icl::lower( int_interval );
	icl::upper( int_interval );
	icl::first( int_interval );
	icl::last( int_interval );
	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;
	icl::disjoint( int_map, int_element );
	icl::disjoint( int_map, int_segment );
	icl::intersects( int_map, int_segment );
	icl::intersects( int_map, int_element );
}

Change History (4)

comment:1 by John Reid <j.reid@…>, 12 years ago

I'm using svn revision 69120 with gcc 4.4.3

comment:2 by Joachim Faulhaber, 12 years ago

Component: intervalICL
Status: newassigned

comment:3 by Joachim Faulhaber, 12 years ago

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

icl::interval<myType> myInterval;

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

Please use

icl::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 );
}

Thanks for using my library and helping to improve it. Joachim

comment:4 by Joachim Faulhaber, 12 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.