| Front Page / Iterators / Iterator Metafunctions / iterator_category |
template<
typename Iterator
>
struct iterator_category
{
typedef typename Iterator::category type;
};
Returns one of the following iterator category tags:
#include <boost/mpl/iterator_category.hpp> #include <boost/mpl/iterator_tags.hpp>
| Parameter | Requirement | Description |
|---|---|---|
| Iterator | Forward Iterator | The iterator to obtain a category for. |
For any Forward Iterators iter:
typedef iterator_category<iter>::type tag;
| Return type: | Integral Constant. |
|---|---|
| Semantics: | tag is forward_iterator_tag if iter is a model of Forward Iterator, bidirectional_iterator_tag if iter is a model of Bidirectional Iterator, or random_access_iterator_tag if iter is a model of Random Access Iterator; |
| Postcondition: |
|
Amortized constant time.
template< typename Tag, typename Iterator >
struct algorithm_impl
{
// O(n) implementation
};
template< typename Iterator >
struct algorithm_impl<random_access_iterator_tag,Iterator>
{
// O(1) implementation
};
template< typename Iterator >
struct algorithm
: algorithm_impl<
iterator_category<Iterator>::type
, Iterator
>
{
};