senf::contiguous_storage_iterator< RandomAccessIterator > Struct Template Reference

Check for contiguous mutable storage. More...

#include <senf/Utils/IteratorTraits.hh>

Inheritance diagram for senf::contiguous_storage_iterator< RandomAccessIterator >:

Detailed Description

template<class RandomAccessIterator>
struct senf::contiguous_storage_iterator< RandomAccessIterator >

Check for contiguous mutable storage.

This type trait returns true, if RandomAccessIterator is an iterator into a contiguous storage area which may be written to. If this is the case, some algorithms may be optimized by directly modifying the underlying storage instead of relying on the STL interface.

// Generic algorithm
template <class Iterator>
void do(Iterator i, boost::false_type)
{
// Access the iterator 'i' via the standard STL interface
}
template<class Iterator>
void do(Iterator i, boost::true_type)
{
typename Iterator::pointer p (senf::storage_iterator(i));
// Manipulate the container by manipulating the data pointed at via 'p'
}
template <class Iterator>
void foo(Iterator i)
{
// ...
// ...
}
    Thie \ref senf::storage_iterator helper function will convert an iterator to a pointer to
    the same element the iterator is referencing.

    This trait will return \c true for pointers. Additionally it should be configured to return
    true for all standard containers which obey above implementation restrictions. This
    typically includes \c std::vector and \c std::basic_string.

    To do so, the template must be specialized for those containers \c iterator type. If
    compiling with g++, this is implemented in \ref IteratorTraits.ih. This file should be
    extended for further compilers or STL implementations if needed.

Definition at line 75 of file IteratorTraits.hh.


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