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/fusion/support/config.hpp>
11 #include <boost/type_traits/add_const.hpp>
12 #include <boost/type_traits/remove_reference.hpp>
13 #include <boost/mpl/fold.hpp>
14 #include <boost/mpl/plus.hpp>
15 #include <boost/mpl/size_t.hpp>
16 #include <boost/mpl/placeholders.hpp>
17 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
18 #include <boost/fusion/mpl/begin.hpp>
19 #include <boost/fusion/mpl/end.hpp>
20 #include <boost/fusion/support/is_segmented.hpp>
22 namespace boost { namespace fusion { namespace detail
24 ///////////////////////////////////////////////////////////////////////////
25 // calculates the size of any segmented data structure.
26 template<typename Sequence>
27 struct segmented_size;
29 ///////////////////////////////////////////////////////////////////////////
30 template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
31 struct segmented_size_impl
33 typename remove_reference<
35 typename result_of::segments<Sequence>::type
39 , mpl::plus<mpl::_1, segmented_size<remove_reference<mpl::_2> > >
43 template<typename Sequence>
44 struct segmented_size_impl<Sequence, false>
45 : result_of::size<Sequence>::type
48 template<typename Sequence>
50 : segmented_size_impl<Sequence>