Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:34:43

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying 
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(FUSION_CATEGORY_OF_07202005_0308)
0008 #define FUSION_CATEGORY_OF_07202005_0308
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/support/tag_of.hpp>
0012 #include <boost/type_traits/is_base_of.hpp>
0013 
0014 namespace boost { namespace fusion
0015 {
0016     // Special tags:
0017     struct boost_tuple_tag; // boost::tuples::tuple tag
0018     struct boost_array_tag; // boost::array tag
0019     struct mpl_sequence_tag; // mpl sequence tag
0020     struct std_pair_tag; // std::pair tag
0021 
0022     struct incrementable_traversal_tag {};
0023 
0024     struct single_pass_traversal_tag
0025         : incrementable_traversal_tag {};
0026 
0027     struct forward_traversal_tag
0028         : single_pass_traversal_tag {};
0029 
0030     struct bidirectional_traversal_tag
0031         : forward_traversal_tag {};
0032 
0033     struct random_access_traversal_tag
0034         : bidirectional_traversal_tag {};
0035 
0036     struct associative_tag {};
0037 
0038     struct unbounded_tag {};
0039 
0040     namespace extension
0041     {
0042         template<typename Tag>
0043         struct category_of_impl
0044         {
0045             template<typename T>
0046             struct apply
0047             {
0048                 typedef typename T::category type;
0049             };
0050         };
0051 
0052         template <>
0053         struct category_of_impl<boost_tuple_tag>;
0054 
0055         template <>
0056         struct category_of_impl<boost_array_tag>;
0057 
0058         template <>
0059         struct category_of_impl<mpl_sequence_tag>;
0060 
0061         template <>
0062         struct category_of_impl<std_pair_tag>;
0063     }
0064 
0065     namespace traits
0066     {
0067         template <typename T>
0068         struct category_of
0069             : extension::category_of_impl<typename fusion::detail::tag_of<T>::type>::
0070                 template apply<T>
0071         {};
0072 
0073         template <typename T>
0074         struct is_associative
0075             : is_base_of<
0076                 associative_tag
0077               , typename category_of<T>::type>
0078         {};
0079 
0080         template <typename T>
0081         struct is_incrementable
0082             : is_base_of<
0083                 incrementable_traversal_tag
0084               , typename category_of<T>::type>
0085         {};
0086 
0087         template <typename T>
0088         struct is_single_pass
0089             : is_base_of<
0090                 single_pass_traversal_tag
0091               , typename category_of<T>::type>
0092         {};
0093 
0094         template <typename T>
0095         struct is_forward
0096             : is_base_of<
0097                 forward_traversal_tag
0098               , typename category_of<T>::type>
0099         {};
0100 
0101         template <typename T>
0102         struct is_bidirectional
0103             : is_base_of<
0104                 bidirectional_traversal_tag
0105               , typename category_of<T>::type>
0106         {};
0107 
0108         template <typename T>
0109         struct is_random_access
0110             : is_base_of<
0111                 random_access_traversal_tag
0112               , typename category_of<T>::type>
0113         {};
0114 
0115         template <typename T>
0116         struct is_unbounded
0117             : is_base_of<
0118                 unbounded_tag
0119               , typename category_of<T>::type>
0120         {};
0121     }
0122 }}
0123 
0124 #endif