Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

category_of

Description

A metafunction that establishes the conceptual classification of a particular Sequence or Iterator (see Iterator Concepts and Sequence Concepts).

Synopsis
namespace traits
{
    template <typename T>
    struct category_of
    {
        typedef unspecified type;
    };
}
Parameters

Parameter

Requirement

Description

T

Any type

The type to query.

Expression Semantics
typedef traits::category_of<T>::type category;

Return type:

For Iterators, the return type is derived from one of:

namespace boost { namespace fusion
{
    struct incrementable_traversal_tag {};

    struct single_pass_traversal_tag
        : incrementable_traversal_tag {};

    struct forward_traversal_tag
        : single_pass_traversal_tag {};

    struct bidirectional_traversal_tag
        : forward_traversal_tag {};

    struct random_access_traversal_tag
        : bidirectional_traversal_tag {};
}}

For Sequences, the return type is derived from one of:

namespace boost { namespace fusion
{
    struct incrementable_sequence_tag {};

    struct single_pass_sequence_tag
        : incrementable_sequence_tag {};

    struct forward_traversal_tag
        : single_pass_sequence_tag {};

    struct bidirectional_traversal_tag
        : forward_traversal_tag {};

    struct random_access_traversal_tag
        : bidirectional_traversal_tag {};
}}

And optionally from:

namespace boost { namespace fusion
{
    struct associative_sequence_tag {};
}}

Semantics: Establishes the conceptual classification of a particular Sequence or Iterator.

Header
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/include/category_of.hpp>
Example
using boost::is_base_of;
typedef traits::category_of<list<> >::type list_category;
typedef traits::category_of<vector<> >::type vector_category;
BOOST_MPL_ASSERT(( is_base_of<forward_traversal_tag, list_category> ));
BOOST_MPL_ASSERT(( is_base_of<random_access_traversal_tag, vector_category> ));

PrevUpHomeNext