PageRenderTime 53ms CodeModel.GetById 46ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/fusion/support/category_of.hpp

http://hadesmem.googlecode.com/
C++ Header | 112 lines | 84 code | 21 blank | 7 comment | 0 complexity | 82854f43cd57993b019c869b425660e7 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2001-2006 Joel de Guzman
  3
  4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
  5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6==============================================================================*/
  7#if !defined(FUSION_CATEGORY_OF_07202005_0308)
  8#define FUSION_CATEGORY_OF_07202005_0308
  9
 10#include <boost/fusion/support/detail/category_of.hpp>
 11#include <boost/fusion/support/tag_of.hpp>
 12#include <boost/type_traits/is_base_of.hpp>
 13
 14namespace boost { namespace fusion
 15{
 16    // Special tags:
 17    struct boost_tuple_tag; // boost::tuples::tuple tag
 18    struct boost_array_tag; // boost::array tag
 19    struct mpl_sequence_tag; // mpl sequence tag
 20    struct std_pair_tag; // std::pair tag
 21
 22    struct incrementable_traversal_tag {};
 23
 24    struct single_pass_traversal_tag
 25        : incrementable_traversal_tag {};
 26
 27    struct forward_traversal_tag
 28        : single_pass_traversal_tag {};
 29
 30    struct bidirectional_traversal_tag
 31        : forward_traversal_tag {};
 32
 33    struct random_access_traversal_tag
 34        : bidirectional_traversal_tag {};
 35
 36    struct associative_tag {};
 37
 38    namespace extension
 39    {
 40        template<typename Tag>
 41        struct category_of_impl
 42        {
 43            template<typename T>
 44            struct apply : detail::fusion_category_of<T> {};
 45        };
 46
 47        template <>
 48        struct category_of_impl<boost_tuple_tag>;
 49
 50        template <>
 51        struct category_of_impl<boost_array_tag>;
 52
 53        template <>
 54        struct category_of_impl<mpl_sequence_tag>;
 55
 56        template <>
 57        struct category_of_impl<std_pair_tag>;
 58    }
 59
 60    namespace traits
 61    {
 62        template <typename T>
 63        struct category_of
 64            : extension::category_of_impl<typename fusion::detail::tag_of<T>::type>::
 65                template apply<T>
 66        {};
 67
 68        template <typename T>
 69        struct is_associative
 70            : is_base_of<
 71                associative_tag
 72              , typename category_of<T>::type>
 73        {};
 74
 75        template <typename T>
 76        struct is_incrementable
 77            : is_base_of<
 78                incrementable_traversal_tag
 79              , typename category_of<T>::type>
 80        {};
 81
 82        template <typename T>
 83        struct is_single_pass
 84            : is_base_of<
 85                single_pass_traversal_tag
 86              , typename category_of<T>::type>
 87        {};
 88
 89        template <typename T>
 90        struct is_forward
 91            : is_base_of<
 92                forward_traversal_tag
 93              , typename category_of<T>::type>
 94        {};
 95
 96        template <typename T>
 97        struct is_bidirectional
 98            : is_base_of<
 99                bidirectional_traversal_tag
100              , typename category_of<T>::type>
101        {};
102
103        template <typename T>
104        struct is_random_access
105            : is_base_of<
106                random_access_traversal_tag
107              , typename category_of<T>::type>
108        {};
109    }
110}}
111
112#endif