fusion: merge of associative iterators/views and the new fold interface

[SVN r58618]
This commit is contained in:
Christopher Schmidt
2010-01-01 22:00:21 +00:00
parent b605617c4f
commit cda74605fc
379 changed files with 28481 additions and 2185 deletions

View File

@ -1,35 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ASSOC_FIND_09242005_1133)
#define FUSION_ASSOC_FIND_09242005_1133
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace detail
{
template <typename Sequence, typename Key>
struct assoc_find
{
typedef typename
mpl::if_<
is_const<Sequence>
, typename Sequence::template meta_find_impl_const<Key>::type
, typename Sequence::template meta_find_impl<Key>::type
>::type
type;
static type
call(Sequence& s)
{
return s.find_impl(mpl::identity<Key>());
}
};
}}}
#endif

View File

@ -1,6 +1,7 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Copyright (c) 2009 Christopher Schmidt
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)
@ -13,7 +14,6 @@
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
@ -31,7 +31,7 @@ namespace detail
struct apply_filter
{
typedef typename mpl::apply1<
Pred, typename result_of::value_of<Iterator>::type>::type type;
Pred, Iterator>::type type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
@ -85,7 +85,7 @@ namespace detail
typedef typename
mpl::apply1<
Pred
, typename result_of::value_of<Shifted>::type
, Shifted
>::type
type;
BOOST_STATIC_CONSTANT(int, value = type::value);
@ -227,26 +227,6 @@ namespace detail
return choose_call(iter, typename traits::category_of<Iterator>::type());
}
};
template <typename First, typename Last, typename Pred>
struct static_seq_find_if : static_find_if<First, Last, Pred>
{
typedef typename static_find_if<First, Last, Pred>::type type;
template <typename Sequence>
static type
call(Sequence const& seq)
{
return static_find_if<First, Last, Pred>::call(fusion::begin(seq));
}
template <typename Sequence>
static type
call(Sequence& seq)
{
return static_find_if<First, Last, Pred>::call(fusion::begin(seq));
}
};
}}}
#endif

View File

@ -8,46 +8,43 @@
#define FUSION_FIND_05052005_1107
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/algorithm/query/detail/assoc_find.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion
{
struct associative_sequence_tag;
namespace result_of
{
template <
typename Sequence
, typename T
, bool is_associative_sequence = traits::is_associative<Sequence>::value >
struct find;
template <typename Sequence, typename T>
struct find<Sequence, T, false>
>
struct find
{
typedef
detail::static_seq_find_if<
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, is_same<mpl::_, T>
, is_same<
typename mpl::if_<
traits::is_associative<Sequence>
, key_of<mpl::_1>
, value_of<mpl::_1>
>::type
, T
>
>
filter;
typedef typename filter::type type;
};
template <typename Sequence, typename T>
struct find<Sequence, T, true>
{
typedef detail::assoc_find<Sequence, T> filter;
typedef typename filter::type type;
};
}
template <typename T, typename Sequence>
@ -59,7 +56,7 @@ namespace boost { namespace fusion
find(Sequence& seq)
{
typedef typename result_of::find<Sequence, T>::filter filter;
return filter::call(seq);
return filter::call(fusion::begin(seq));
}
template <typename T, typename Sequence>
@ -67,7 +64,7 @@ namespace boost { namespace fusion
find(Sequence const& seq)
{
typedef typename result_of::find<Sequence const, T>::filter filter;
return filter::call(seq);
return filter::call(fusion::begin(seq));
}
}}

View File

@ -10,6 +10,10 @@
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/mpl/bind.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
@ -20,13 +24,18 @@ namespace boost { namespace fusion
template <typename Sequence, typename Pred>
struct find_if
{
typedef typename
typedef
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>::type
type;
, mpl::bind1<
typename mpl::lambda<Pred>::type
, mpl::bind1<mpl::quote1<value_of>,mpl::_1>
>
>
filter;
typedef typename filter::type type;
};
}
@ -38,14 +47,7 @@ namespace boost { namespace fusion
>::type
find_if(Sequence& seq)
{
typedef
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>
filter;
typedef typename result_of::find_if<Sequence, Pred>::filter filter;
return filter::call(fusion::begin(seq));
}
@ -53,14 +55,7 @@ namespace boost { namespace fusion
inline typename result_of::find_if<Sequence const, Pred>::type const
find_if(Sequence const& seq)
{
typedef
detail::static_find_if<
typename result_of::begin<Sequence const>::type
, typename result_of::end<Sequence const>::type
, Pred
>
filter;
typedef typename result_of::find_if<Sequence const, Pred>::filter filter;
return filter::call(fusion::begin(seq));
}
}}