Modify

Opened 6 years ago

Closed 6 years ago

#5207 closed Bugs (fixed)

ICL compile errors

Reported by: John Reid <j.reid@…> Owned by: jofaber
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 );
}

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by John Reid <j.reid@…>

I'm using svn revision 69120 with gcc 4.4.3

comment:2 Changed 6 years ago by jofaber

  • Component changed from interval to ICL
  • Status changed from new to assigned

comment:3 Changed 6 years ago by jofaber

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 Changed 6 years ago by jofaber

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain jofaber.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.