new cleaner(?) implementation for segmented fusion

[SVN r73644]
This commit is contained in:
Eric Niebler
2011-08-11 04:14:50 +00:00
parent 00b2cfc52e
commit d9c5b32687
28 changed files with 2171 additions and 1496 deletions

View File

@ -4,8 +4,8 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_SEGMENTS_04052005_1141)
#define FUSION_SEGMENTS_04052005_1141
#if !defined(BOOST_FUSION_SEGMENTS_04052005_1141)
#define BOOST_FUSION_SEGMENTS_04052005_1141
#include <boost/fusion/support/tag_of.hpp>
@ -27,9 +27,10 @@ namespace boost { namespace fusion
template <typename Sequence>
struct segments
{
typedef typename traits::tag_of<Sequence>::type tag_type;
typedef typename
extension::segments_impl<typename traits::tag_of<Sequence>::type>::
template apply<Sequence>::type
extension::segments_impl<tag_type>::template apply<Sequence>::type
type;
};
}
@ -38,18 +39,16 @@ namespace boost { namespace fusion
typename result_of::segments<Sequence>::type
segments(Sequence & seq)
{
return
extension::segments_impl<typename traits::tag_of<Sequence>::type>::
template apply<Sequence>::call(seq);
typedef typename traits::tag_of<Sequence>::type tag_type;
return extension::segments_impl<tag_type>::template apply<Sequence>::call(seq);
}
template <typename Sequence>
typename result_of::segments<Sequence const>::type
segments(Sequence const& seq)
{
return
extension::segments_impl<typename traits::tag_of<Sequence>::type>::
template apply<Sequence const>::call(seq);
typedef typename traits::tag_of<Sequence const>::type tag_type;
return extension::segments_impl<tag_type>::template apply<Sequence const>::call(seq);
}
}}

View File

@ -1,57 +1,57 @@
/*=============================================================================
Copyright (c) 2006 Eric Niebler
Copyright (c) 2011 Eric Niebler
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_SIZE_S_08112006_1141)
#define FUSION_SIZE_S_08112006_1141
#if !defined(BOOST_FUSION_SIZE_S_08112006_1141)
#define BOOST_FUSION_SIZE_S_08112006_1141
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/support/ext_/is_segmented.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/ext_/segments.hpp>
#include <boost/fusion/support/ext_/is_segmented.hpp>
namespace boost { namespace fusion
{
///////////////////////////////////////////////////////////////////////////
// calculates the size of any segmented data structure.
template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
template<typename Sequence>
struct segmented_size;
namespace detail
{
struct size_plus
{
template<typename Sig>
struct result;
///////////////////////////////////////////////////////////////////////////
template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
struct segmented_size_impl
: mpl::fold<
typename remove_reference<
typename add_const<
typename result_of::segments<Sequence>::type
>::type
>::type,
mpl::size_t<0>,
mpl::plus<mpl::_1, segmented_size<mpl::_2> >
>::type
{};
template<typename This, typename State, typename Seq>
struct result<This(State, Seq)>
: mpl::plus<
segmented_size<typename remove_reference<Seq>::type>
, typename remove_reference<State>::type
>
{};
};
template<typename Sequence>
struct segmented_size_impl<Sequence, false>
: result_of::size<Sequence>::type
{};
}
///////////////////////////////////////////////////////////////////////////
template<typename Sequence, bool IsSegmented>
template<typename Sequence>
struct segmented_size
: result_of::fold<
typename result_of::segments<Sequence>::type
, mpl::size_t<0>
, detail::size_plus
>::type
: detail::segmented_size_impl<Sequence>
{};
template<typename Sequence>
struct segmented_size<Sequence, false>
: result_of::size<Sequence>
{};
}}
#endif