CGAL 6.0 - Handles and Circulators
Loading...
Searching...
No Matches

Iterators and circulators as well as different categories of circulators can be distinguished with the use of discriminating functions and the following circulator tags.

A couple of base classes simplify the task of writing own circulators. They declare the appropriate tags and the local types needed for circulators. To use the tags or base classes only it is sufficient to include:

See also
query_circulator_or_iterator
Circulator_traits
Assert_circulator
CGAL_For_all
is_empty_range
Circulator

Example

The above declarations can be used to distinguish between iterators and circulators and between different circulator categories. The assertions can be used to protect a templatized algorithm against instantiations that do not fulfill the requirements. The following example program illustrates both.


File Circulator/circulator_prog3.cpp

#include <cassert>
#include <list>
#include <CGAL/circulator.h>
template <class C> inline int foo( C c, std::forward_iterator_tag) {
return 1;
}
template <class C> inline int foo( C c, std::random_access_iterator_tag) {
return 2;
}
template <class I> inline int foo( I i, CGAL::Iterator_tag) {
return 3;
}
template <class C> inline int foo( C c, CGAL::Circulator_tag) {
typedef std::iterator_traits<C> Traits;
typedef typename Traits::iterator_category iterator_category;
return foo( c, iterator_category());
}
template <class IC> inline int foo( IC ic) {
typedef typename Traits::category category;
return foo( ic, category());
}
int main() {
F f = F();
R r = R();
std::list<int> l;
assert( foo( f) == 1);
assert( foo( r) == 2);
assert( foo( l.begin()) == 3);
return 0;
}
void Assert_iterator(const I &i)
checks at compile time if its argument is an iterator.
void Assert_circulator(const C &c)
checks at compile time if its argument is a circulator.
void Assert_random_access_category(const IC &ic)
void Assert_forward_category(const IC &ic)
A tag for any circulator type.
Definition: circulator_bases.h:53
The circulator traits class distinguishes between circulators and iterators.
Definition: circulator.h:343
Definition: circulator_bases.h:94
A tag for any iterator type.
Definition: circulator_bases.h:59
Definition: circulator_bases.h:106

Classes

struct  CGAL::Circulator_tag
 A tag for any circulator type. More...
 
struct  CGAL::Iterator_tag
 A tag for any iterator type. More...
 
struct  CGAL::Forward_circulator_tag
 
struct  CGAL::Bidirectional_circulator_tag
 
struct  CGAL::Random_access_circulator_tag