]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/intrinsic/size.hpp
2a3cb7f8230d8747677d10297131ca0debfe25e3
[rsem.git] / boost / fusion / sequence / intrinsic / size.hpp
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_SIZE_05052005_0214)
8 #define FUSION_SIZE_05052005_0214
9
10 #include <boost/mpl/int.hpp>
11 #include <boost/fusion/support/tag_of.hpp>
12
13 namespace boost { namespace fusion
14 {
15     // Special tags:
16     struct sequence_facade_tag;
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     namespace extension
23     {
24         template <typename Tag>
25         struct size_impl
26         {
27             template <typename Sequence>
28             struct apply : Sequence::size {};
29         };
30
31         template <>
32         struct size_impl<sequence_facade_tag>
33         {
34             template <typename Sequence>
35             struct apply : Sequence::template size<Sequence> {};
36         };
37  
38         template <>
39         struct size_impl<boost_tuple_tag>;
40  
41         template <>
42         struct size_impl<boost_array_tag>;
43
44         template <>
45         struct size_impl<mpl_sequence_tag>;
46
47         template <>
48         struct size_impl<std_pair_tag>;
49     }
50
51     namespace result_of
52     {
53         template <typename Sequence>
54         struct size
55             : extension::size_impl<typename detail::tag_of<Sequence>::type>::
56         template apply<Sequence>
57
58         {
59             typedef typename extension::size_impl<typename detail::tag_of<Sequence>::type>::
60             template apply<Sequence>::type size_application;
61             BOOST_STATIC_CONSTANT(int, value = size_application::value);
62         };
63     }
64
65     template <typename Sequence>
66     inline typename result_of::size<Sequence>::type
67     size(Sequence const&)
68     {
69         typedef typename result_of::size<Sequence>::type result;
70         return result();
71     }
72 }}
73
74 #endif