]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/intrinsic/size.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / sequence / intrinsic / size.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2011 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/utility/enable_if.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/mpl/int.hpp>
13 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
14 #include <boost/fusion/support/tag_of.hpp>
15 #include <boost/fusion/support/is_segmented.hpp>
16 #include <boost/fusion/sequence/intrinsic/detail/segmented_size.hpp>
17
18 namespace boost { namespace fusion
19 {
20     // Special tags:
21     struct sequence_facade_tag;
22     struct boost_tuple_tag; // boost::tuples::tuple tag
23     struct boost_array_tag; // boost::array tag
24     struct mpl_sequence_tag; // mpl sequence tag
25     struct std_pair_tag; // std::pair tag
26
27     namespace extension
28     {
29         template <typename Tag>
30         struct size_impl
31         {
32             template<typename Sequence>
33             struct unsegmented_size : Sequence::size {};
34
35             template <typename Sequence>
36             struct apply
37               : mpl::if_<
38                     traits::is_segmented<Sequence>
39                   , detail::segmented_size<Sequence>
40                   , unsegmented_size<Sequence>
41                 >::type
42             {};
43         };
44
45         template <>
46         struct size_impl<sequence_facade_tag>
47         {
48             template <typename Sequence>
49             struct apply : Sequence::template size<Sequence> {};
50         };
51  
52         template <>
53         struct size_impl<boost_tuple_tag>;
54  
55         template <>
56         struct size_impl<boost_array_tag>;
57
58         template <>
59         struct size_impl<mpl_sequence_tag>;
60
61         template <>
62         struct size_impl<std_pair_tag>;
63     }
64
65     namespace result_of
66     {
67         template <typename Sequence>
68         struct size
69             : extension::size_impl<typename detail::tag_of<Sequence>::type>::
70         template apply<Sequence>
71
72         {
73             typedef typename extension::size_impl<typename detail::tag_of<Sequence>::type>::
74             template apply<Sequence>::type size_application;
75             BOOST_STATIC_CONSTANT(int, value = size_application::value);
76         };
77     }
78
79     template <typename Sequence>
80     inline typename result_of::size<Sequence>::type
81     size(Sequence const&)
82     {
83         typedef typename result_of::size<Sequence>::type result;
84         return result();
85     }
86 }}
87
88 #endif