[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| IteratorTraits Struct Template Reference |
--- | --- | ---

Export associated information for each image iterator. More...

`#include "vigra/iteratortraits.hxx"`

## Detailed Description

### template<class T>
struct vigra::IteratorTraits< T >

Export associated information for each image iterator.

The IteratorTraits class contains the following fields:

        template <class T>
        struct IteratorTraits
        {
            typedef T                                     Iterator;
            typedef Iterator                              iterator;
            typedef typename iterator::iterator_category  iterator_category;
            typedef typename iterator::value_type         value_type;
            typedef typename iterator::reference          reference;
            typedef typename iterator::index_reference    index_reference;
            typedef typename iterator::pointer            pointer;
            typedef typename iterator::difference_type    difference_type;
            typedef typename iterator::row_iterator       row_iterator;
            typedef typename iterator::column_iterator    column_iterator;
            typedef StandardAccessor<value_type>          DefaultAccessor;
            typedef StandardAccessor<value_type>          default_accessor;

            typedef VigraTrueType/VigraFalseType          hasConstantStrides;
        };

By (partially) specializing this template for an iterator class the defaults given above can be changed as appropriate. For example, iterators for rgb images are associated with `RGBAccessor<value_type>` instead of `StandardAccessor<value_type>`. To get the accessor associated with a given iterator, use code like this:

        template <class Iterator>
        void foo(Iterator i)
        {
            typedef typename IteratorTraits<Iterator>::DefaultAccessor Accessor;
            Accessor a;
            ...
        }

This technique is, for example, used by the Iterator Based Argument Object Factories. The possibility to retrieve the default accessor by means of a traits class is especially important since this information is not contained in the iterator directly.

The member `hasConstantStrides` is useful for certain optimizations: it helps to decide whether we can replace iterator operations such as `iter++` ot `iter =+ n` with corresponding pointer operations (which may be faster), where the pointer is obtained as the address of iterator's pointee (the object the iterator currently refers to). This flag would be tt>VigraFalseType for a `std::list<int>iterator`, but is `VigraTrueType` for most VIGRA iterators.

#include "vigra/iteratortraits.hxx" Namespace: vigra

The documentation for this struct was generated from the following file:

- vigra/iteratortraits.hxx

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.4.0 (21 Dec 2005)