VIGRA - VIGRA: IteratorTraits Struct Template Reference

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

| IteratorTraits [Image Iterators] |

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

`#include <vigra/iteratortraits.hxx>`

List of all members.

## 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 typename
             AccessorTraits<value_type>::default_accessor DefaultAccessor;
            typedef DefaultAccessor                       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++` or `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 `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 (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python VIGRA 1.6.0 (13 Aug 2008)