1 /*=============================================================================
2 Copyright (c) 2011 Eric Niebler
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
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>
21 namespace boost { namespace fusion { namespace detail
23 ///////////////////////////////////////////////////////////////////////////
24 // calculates the size of any segmented data structure.
25 template<typename Sequence>
26 struct segmented_size;
28 ///////////////////////////////////////////////////////////////////////////
29 template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
30 struct segmented_size_impl
32 typename remove_reference<
34 typename result_of::segments<Sequence>::type
38 , mpl::plus<mpl::_1, segmented_size<remove_reference<mpl::_2> > >
42 template<typename Sequence>
43 struct segmented_size_impl<Sequence, false>
44 : result_of::size<Sequence>::type
47 template<typename Sequence>
49 : segmented_size_impl<Sequence>