Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost][boost-users][ICL] ICL Compilation errors. Ticket #5207
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-02-24 08:42:42


2011/2/24 John Reid <j.reid_at_[hidden]>:
> On 24/02/11 11:51, Joachim Faulhaber wrote:
>>
>> (3) More compilability issues
>>
>> 2011/2/23 John Reid<j.reid_at_[hidden]>:
>>>
>>> I'm interested to hear reasons why the following don't compile when using
>>> static bounds:
>>>
>>> icl::add( icl::interval_set<  int>(), 0 );
>>> icl::add( icl::interval_set<  int>(), icl::interval<  int>::type( 0, 1 )
>>> );
>>> icl::interval_set<  int>() += 0;
>>> icl::interval_set<  int>() += icl::interval<  int>::type( 0, 1 );
>>>
>>> icl::subtract( icl::interval_set<  int>(), 0 );
>>> icl::subtract( icl::interval_set<  int>(), icl::interval<  int>::type( 0,
>>> 1
>>> ) );
>>> icl::interval_set<  int>() -= 0;
>>> icl::interval_set<  int>() -= icl::interval<  int>::type( 0, 1 );
>>>
>>> icl::interval_set<  int>()&= 0;
>>> icl::interval_set<  int>()&= icl::interval<  int>::type( 0, 1 );
>>>
>>> icl::interval_set<  int>() ^= ( icl::interval<  int>::type( 0, 1 ) );
>>>
>>>
>>> They all seem reasonable operations to me. In particular, for a discrete
>>> domain, operations like icl::interval_set<  int>() += 0 make sense to me.
>>> That is the following are equivalent:
>>> icl::interval_set<  int>() += 0
>>> icl::interval_set<  int>() += icl::interval<  int>::type( 0, 1 );
>>
>> Yes, you are right! The code you are giving should compile and it
>> actually compiles on my machine with different msvc compilers. I guess
>> it also compiles for gcc. If the problem persists try to generate a
>> minimal code example so I can look again.
>
> We are still talking about static intervals. You did try setting the #define
> for static intervals?

Yes.

> If you did, then my minimal example consists of
> putting the code above in the function f() below:
>
> #define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
> #include <boost/icl/interval_set.hpp>
> #include <boost/icl/interval_map.hpp>
>
> void f() {
>        namespace icl = ::boost::icl;
> }
>

The reason that your code does not compile with gcc but compiles with
msvc is, that gcc is pickier when you try to pass a temporary object
to a reference parameter. When I pass the non-temporary object
'int_set' to the function calls, the code compiles.

#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
#include <boost/icl/interval_set.hpp>
#include <boost/icl/interval_map.hpp>

void f() {
  namespace icl = ::boost::icl;

  icl::interval_set<int> int_set;
  icl::add( int_set, 0 );
  icl::add( int_set, icl::interval< int>::type( 0, 1 ) );
  int_set += 0;
  int_set += icl::interval< int>::type( 0, 1 );

  icl::subtract( int_set, 0 );
  icl::subtract( int_set, icl::interval< int >::type( 0, 1 ) );
  int_set -= 0;
  int_set -= icl::interval< int >::type( 0, 1 );

  int_set &= 0;
  int_set &= icl::interval< int >::type( 0, 1 );

  int_set ^= ( icl::interval< int >::type( 0, 1 ) );
}

Regards,
Joachim

-- 
Interval Container Library [Boost.Icl]
http://www.joachim-faulhaber.de

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net