...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A metafunction that establishes the conceptual classification of a particular Sequence or Iterator (see Iterator Concepts and Sequence Concepts).
namespace traits { template <typename T> struct category_of { typedef unspecified type; }; }
Parameter |
Requirement |
Description |
---|---|---|
|
Any type |
The type to query. |
typedef traits::category_of<T>::type category;
Return type:
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 {}; }}
And optionally from:
namespace boost { namespace fusion { struct associative_tag {}; }}
Semantics: Establishes the conceptual classification of a particular Sequence or Iterator.
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/include/category_of.hpp>
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> ));