]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/intrinsic/detail/segmented_size.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / sequence / intrinsic / detail / segmented_size.hpp
1 /*=============================================================================
2     Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_SIZE_08112006_1141)
8 #define BOOST_FUSION_SEGMENTED_SIZE_08112006_1141
9
10 #include <boost/type_traits/add_const.hpp>
11 #include <boost/type_traits/remove_reference.hpp>
12 #include <boost/mpl/fold.hpp>
13 #include <boost/mpl/plus.hpp>
14 #include <boost/mpl/size_t.hpp>
15 #include <boost/mpl/placeholders.hpp>
16 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
17 #include <boost/fusion/mpl/begin.hpp>
18 #include <boost/fusion/mpl/end.hpp>
19 #include <boost/fusion/support/is_segmented.hpp>
20
21 namespace boost { namespace fusion { namespace detail
22 {
23     ///////////////////////////////////////////////////////////////////////////
24     // calculates the size of any segmented data structure.
25     template<typename Sequence>
26     struct segmented_size;
27
28     ///////////////////////////////////////////////////////////////////////////
29     template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
30     struct segmented_size_impl
31       : mpl::fold<
32             typename remove_reference<
33                 typename add_const<
34                     typename result_of::segments<Sequence>::type
35                 >::type
36             >::type
37           , mpl::size_t<0>
38           , mpl::plus<mpl::_1, segmented_size<remove_reference<mpl::_2> > >
39         >::type
40     {};
41
42     template<typename Sequence>
43     struct segmented_size_impl<Sequence, false>
44       : result_of::size<Sequence>::type
45     {};
46
47     template<typename Sequence>
48     struct segmented_size
49       : segmented_size_impl<Sequence>
50     {};
51
52 }}}
53
54 #endif