// Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany). // All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Interval_support/include/CGAL/Interval_traits.h $ // $Id: Interval_traits.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Hemmer // // ============================================================================ /*! \file CGAL/Interval_traits.h This is experimental */ /* bounds-related Interval functions */ // template T lower(const Interval& x); // template T upper(const Interval& x); // template T width(const Interval& x); // template T median(const Interval& x); // template T norm(const Interval& x); /* bounds-related Interval functions */ //// template bool empty(const Interval& b); // template bool singleton(const Interval& x); // template bool zero_in(const Interval& b); // template bool in(const T& r, const Interval& b); // template bool equal(const Interval& x, const Interval& y); // template bool overlap(const Interval& x, const Interval& y); // template bool subset(const Interval& a, const Interval& b); // template bool proper_subset(const Interval& a, const Interval& b); /* set manipulation interval functions */ // template Interval intersection(const Interval& x, const Interval& y); // template Interval hull(const Interval& x, const Interval& y); #ifndef CGAL_INTERVAL_TRAITS_H #define CGAL_INTERVAL_TRAITS_H #include #include #include #include namespace CGAL { namespace internal{ template class Interval_traits_base{ public: typedef Interval_traits_base Self; typedef T Type; // typedef T Interval; typedef CGAL::Tag_false Is_interval; typedef CGAL::Tag_false With_empty_interval; typedef CGAL::Null_functor Lower; typedef CGAL::Null_functor Upper; typedef CGAL::Null_functor Width; typedef CGAL::Null_functor Median; typedef CGAL::Null_functor Norm; typedef CGAL::Null_functor Empty; typedef CGAL::Null_functor Singleton; typedef CGAL::Null_functor In; typedef CGAL::Null_functor Zero_in; typedef CGAL::Null_functor Equal; typedef CGAL::Null_functor Overlap; typedef CGAL::Null_functor Subset; typedef CGAL::Null_functor Proper_Subset; typedef CGAL::Null_functor Intersection; typedef CGAL::Null_functor Hull; }; } template class Interval_traits : public internal::Interval_traits_base{}; class Exception_intersection_is_empty{}; // function returning type Bound template inline typename Interval_traits::Bound lower(const Interval& interval) { typename Interval_traits::Lower lower; return lower(interval); } template inline typename Interval_traits::Bound upper(const Interval& interval) { typename Interval_traits::Upper upper; return upper(interval); } template inline typename Interval_traits::Bound width(Interval interval) { typename Interval_traits::Width width; return width(interval); } template inline typename Interval_traits::Bound median(Interval interval) { typename Interval_traits::Median median; return median(interval); } template inline typename Interval_traits::Bound norm(Interval interval) { typename Interval_traits::Norm norm; return norm(interval); } // functions returning bool template inline typename Interval_traits::Empty::result_type empty(Interval interval) { typename Interval_traits::Empty empty; return empty(interval); } template inline typename Interval_traits::Singleton::result_type singleton(Interval interval) { typename Interval_traits::Singleton singleton; return singleton(interval); } template inline typename Interval_traits::In::result_type in(typename Interval_traits::Bound x, Interval interval) { typename Interval_traits::In in; return in(x,interval); } template inline typename Interval_traits::Zero_in::result_type zero_in(Interval interval) { typename Interval_traits::Zero_in zero_in; return zero_in(interval); } // This ones should be removed, since even boost_1_35_0 has changed to zero_in template inline typename Interval_traits::Zero_in::result_type in_zero(Interval interval) { typename Interval_traits::Zero_in zero_in; return zero_in(interval); } template inline typename Interval_traits::Equal::result_type equal(Interval interval1,Interval interval2) { typename Interval_traits::Equal equal; return equal(interval1,interval2); } template inline typename Interval_traits::Overlap::result_type overlap(Interval interval1, Interval interval2) { typename Interval_traits::Overlap overlap; return overlap(interval1, interval2); } template inline typename Interval_traits::Subset::result_type subset(Interval interval1, Interval interval2) { typename Interval_traits::Subset subset; return subset(interval1, interval2); } template inline typename Interval_traits::Proper_subset::result_type proper_subset(Interval interval1, Interval interval2) { typename Interval_traits::Proper_subset proper_subset; return proper_subset(interval1, interval2); } // Set operations, functions returing Interval //the enable_if is need for MSVC as it is not able to eliminate //the function if Interval_traits::Intersection has no result_type //(like Null_functor) template inline typename Interval_traits::Intersection::result_type intersection(Interval interval1, Interval interval2, typename boost::enable_if< typename Interval_traits::Is_interval >::type* = nullptr ) { typename Interval_traits::Intersection intersection; return intersection(interval1, interval2); } template inline typename Interval_traits::Hull::result_type hull(Interval interval1, Interval interval2, typename boost::enable_if< boost::is_same< typename Interval_traits::Is_interval, Tag_true > >::type* = nullptr) { typename Interval_traits::Hull hull; return hull(interval1, interval2); } } //namespace CGAL #endif // CGAL_INTERVAL_TRAITS_H