explicitly check that the Interval template parameter is an interval.

MSVC is not able to eliminate the function even when the functor used
is Null_functor that has no result_type.
This commit is contained in:
Sébastien Loriot 2012-01-20 13:08:32 +00:00
parent 5f642cffd5
commit a1fdcd6170
2 changed files with 22 additions and 6 deletions

View File

@ -52,6 +52,8 @@
#define CGAL_INTERVAL_TRAITS_H #define CGAL_INTERVAL_TRAITS_H
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>
namespace CGAL { namespace CGAL {
@ -192,16 +194,27 @@ proper_subset(Interval interval1, Interval interval2) {
// Set operations, functions returing Interval // Set operations, functions returing Interval
//the enable_if is need for MSVC as it is not able to eliminate
//the function if Interval_traits<Interval>::Intersection has no result_type
//(like Null_functor)
template<typename Interval> inline template<typename Interval> inline
typename Interval_traits<Interval>::Intersection::result_type typename Interval_traits<Interval>::Intersection::result_type
intersection(Interval interval1, Interval interval2) { intersection(Interval interval1, Interval interval2, typename boost::enable_if<
boost::is_same<
typename Interval_traits<Interval>::Is_interval,
Tag_true > >::type* = NULL
) {
typename Interval_traits<Interval>::Intersection intersection; typename Interval_traits<Interval>::Intersection intersection;
return intersection(interval1, interval2); return intersection(interval1, interval2);
} }
template<typename Interval> inline template<typename Interval> inline
typename Interval_traits<Interval>::Hull::result_type typename Interval_traits<Interval>::Hull::result_type
hull(Interval interval1, Interval interval2) { hull(Interval interval1, Interval interval2, typename boost::enable_if<
boost::is_same<
typename Interval_traits<Interval>::Is_interval,
Tag_true > >::type* = NULL)
{
typename Interval_traits<Interval>::Hull hull; typename Interval_traits<Interval>::Hull hull;
return hull(interval1, interval2); return hull(interval1, interval2);
} }

View File

@ -50,10 +50,13 @@ inline bool check_tag( Tag_false) {return false;}
struct Null_tag {}; struct Null_tag {};
struct Null_functor { struct Null_functor {
#if defined(BOOST_MSVC) //temporary fix for VC //SL: I commented the following because I fixed
typedef Null_tag result_type; //in Interval_traits.h the global functions intersection and hull
typedef Null_tag second_argument_type; //to check that the type is really an interval
#endif // #if defined(BOOST_MSVC) //temporary fix for VC
// typedef Null_tag result_type;
// typedef Null_tag second_argument_type;
// #endif
}; };