// ====================================================================== // // Copyright (c) 2002 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------- // // release : // release_date : // // file : include/CGAL/Trivial_iterator.h // revision : $Revision$ // revision_date : $Date$ // author(s) : Sylvain Pion // // coordinator : Mariette Yvinec // // ====================================================================== #ifndef CGAL_TRIVIAL_ITERATOR_H #define CGAL_TRIVIAL_ITERATOR_H #include #include CGAL_BEGIN_NAMESPACE // TODO : // - comparison operators should be global, but it causes problems... // - Have a look at Boost's concept_checking and archetypes : // http://www.boost.org/libs/concept_check/concept_check.htm class Trivial_iterator_tag{}; #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT template < class I, class Ref, class Ptr, class Val, class Dist > #else template #endif class Trivial_iterator { public: typedef I Iterator; #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT typedef Trivial_iterator Self; typedef Val value_type; typedef Dist difference_type; typedef Ref reference; typedef Ptr pointer; #else typedef Trivial_iterator Self; typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::reference reference; typedef typename std::iterator_traits::pointer pointer; #endif typedef Trivial_iterator_tag iterator_category; // Special for circulators. typedef I_Circulator_size_traits C_S_Traits; typedef typename C_S_Traits::size_type size_type; Trivial_iterator() {} Trivial_iterator(const I &i) : base_(i) {} // To allow conversion from iterator to const_iterator. #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT template Trivial_iterator(const Trivial_iterator &t) : base_(t.base()) {} #else template Trivial_iterator(const Trivial_iterator &t) : base_(t.base()) {} #endif reference operator*() const { return *base_; } pointer operator->() const { return &*base_; } bool operator==(const Trivial_iterator &b) const { return base()==b.base(); } bool operator!=(const Trivial_iterator &b) const { return base()!=b.base(); } private: const Iterator & base() const { return base_; } Iterator base_; }; class Trivial_comparable_iterator_tag{}; #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT template < class I, class Ref, class Ptr, class Val, class Dist > #else template #endif class Trivial_comparable_iterator { public: typedef I Iterator; #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT typedef Trivial_comparable_iterator Self; typedef Val value_type; typedef Dist difference_type; typedef Ref reference; typedef Ptr pointer; #else typedef Trivial_comparable_iterator Self; typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::reference reference; typedef typename std::iterator_traits::pointer pointer; #endif typedef Trivial_comparable_iterator_tag iterator_category; // Special for circulators. typedef I_Circulator_size_traits C_S_Traits; typedef typename C_S_Traits::size_type size_type; Trivial_comparable_iterator() {} Trivial_comparable_iterator(const I &i) : base_(i) {} // To allow conversion from iterator to const_iterator. #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT template Trivial_comparable_iterator(const Trivial_comparable_iterator &t) : base_(t.base()) {} #else template Trivial_comparable_iterator(const Trivial_comparable_iterator &t) : base_(t.base()) {} #endif reference operator*() const { return *base_; } pointer operator->() const { return &*base_; } bool operator==(const Trivial_comparable_iterator &b) const { return base()==b.base(); } bool operator!=(const Trivial_comparable_iterator &b) const { return base()!=b.base(); } bool operator< (const Trivial_comparable_iterator &b) const { return base()< b.base(); } bool operator> (const Trivial_comparable_iterator &b) const { return base()> b.base(); } bool operator<=(const Trivial_comparable_iterator &b) const { return base()<=b.base(); } bool operator>=(const Trivial_comparable_iterator &b) const { return base()>=b.base(); } private: const Iterator & base() const { return base_; } Iterator base_; }; // Some macros depending on CGAL_NO_CONCEPT_CHECKING. #ifndef CGAL_NO_CONCEPT_CHECKING # define CGAL_TRIVIAL_ITERATOR_CHECKER(X) CGAL::Trivial_iterator # define CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER(X) \ CGAL::Trivial_comparable_iterator #else # define CGAL_TRIVIAL_ITERATOR_CHECKER(X) X # define CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER(X) X #endif // This macro added to workaround yet another VC++ deficiency. #if defined CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT && \ !defined CGAL_NO_CONCEPT_CHECKING # define CGAL_TRIVIAL_ITERATOR_CHECKER_POINTER(X) \ CGAL::Trivial_iterator # define CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(X) \ CGAL::Trivial_comparable_iterator #else # define CGAL_TRIVIAL_ITERATOR_CHECKER_POINTER(X) \ CGAL_TRIVIAL_ITERATOR_CHECKER(X*) # define CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(X) \ CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER(X*) #endif // For backward compatibility (can be removed soon, it's not been release) #define CGAL_COMPARABLE_ITERATOR_CHECKER(X) \ CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER(X) #define CGAL_COMPARABLE_ITERATOR_CHECKER_POINTER(X) \ CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(X) CGAL_END_NAMESPACE #endif // CGAL_TRIVIAL_ITERATOR_H