forked from boostorg/fusion
Initial move from Spirit CVS
[SVN r34896]
This commit is contained in:
15
include/boost/fusion/algorithm/iteration.hpp
Normal file
15
include/boost/fusion/algorithm/iteration.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ALGORITHM_ITERATION_10022005_0549)
|
||||
#define FUSION_ALGORITHM_ITERATION_10022005_0549
|
||||
|
||||
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
|
||||
#endif
|
66
include/boost/fusion/algorithm/iteration/accumulate.hpp
Normal file
66
include/boost/fusion/algorithm/iteration/accumulate.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ACCUMULATE_09172005_1032)
|
||||
#define FUSION_ACCUMULATE_09172005_1032
|
||||
|
||||
#include <boost/fusion/algorithm/iteration/detail/fold.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename State, typename F>
|
||||
struct accumulate
|
||||
{
|
||||
typedef typename
|
||||
detail::static_fold<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type
|
||||
, State
|
||||
, F
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename result_of::accumulate<Sequence, State, F>::type
|
||||
accumulate(Sequence& seq, State const& state, F const& f)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename result_of::accumulate<Sequence const, State, F>::type
|
||||
accumulate(Sequence const& seq, State const& state, F const& f)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
typename result_of::begin<Sequence const>::type
|
||||
, typename result_of::end<Sequence const>::type>()
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
99
include/boost/fusion/algorithm/iteration/detail/fold.hpp
Normal file
99
include/boost/fusion/algorithm/iteration/detail/fold.hpp
Normal file
@ -0,0 +1,99 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FOLD_05052005_1211)
|
||||
#define FUSION_FOLD_05052005_1211
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
// Unary arguments version
|
||||
|
||||
template <typename F>
|
||||
struct apply_fold_result
|
||||
{
|
||||
template <typename Value, typename State>
|
||||
struct apply
|
||||
{
|
||||
typedef typename F::template result<Value, State>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Iterator, typename State, typename F>
|
||||
struct fold_apply
|
||||
: mpl::apply<apply_fold_result<F>, typename result_of::value_of<Iterator>::type, State>
|
||||
{};
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct static_fold;
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct next_result_of_fold
|
||||
{
|
||||
typedef typename
|
||||
static_fold<
|
||||
typename result_of::next<First>::type
|
||||
, Last
|
||||
, typename fold_apply<First, State, F>::type
|
||||
, F
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct static_fold
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
result_of::equal_to<First, Last>
|
||||
, mpl::identity<State>
|
||||
, next_result_of_fold<First, Last, State, F>
|
||||
>::type
|
||||
result;
|
||||
|
||||
typedef typename result::type type;
|
||||
};
|
||||
|
||||
// terminal case
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
inline State const&
|
||||
fold(First const&, Last const&, State const& state, F const&, mpl::true_)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
// non-terminal case
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
inline typename static_fold<First, Last, State, F>::type
|
||||
fold(
|
||||
First const& first
|
||||
, Last const& last
|
||||
, State const& state
|
||||
, F const& f
|
||||
, mpl::false_)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f(*first, state)
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>()
|
||||
);
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
35
include/boost/fusion/algorithm/iteration/detail/for_each.hpp
Normal file
35
include/boost/fusion/algorithm/iteration/detail/for_each.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FOR_EACH_05052005_1028)
|
||||
#define FUSION_FOR_EACH_05052005_1028
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline void
|
||||
for_each(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline void
|
||||
for_each(First const& first, Last const& last, F const& f, mpl::false_)
|
||||
{
|
||||
f(*first);
|
||||
detail::for_each(fusion::next(first), last, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
67
include/boost/fusion/algorithm/iteration/fold.hpp
Normal file
67
include/boost/fusion/algorithm/iteration/fold.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FOLD_05052005_1214)
|
||||
#define FUSION_FOLD_05052005_1214
|
||||
|
||||
#include <boost/fusion/algorithm/iteration/detail/fold.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename State, typename F>
|
||||
struct fold
|
||||
{
|
||||
typedef typename
|
||||
detail::static_fold<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type
|
||||
, State
|
||||
, F
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename result_of::fold<Sequence, State, F>::type
|
||||
fold(Sequence& seq, State const& state, F const& f)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename result_of::fold<Sequence const, State, F>::type
|
||||
fold(Sequence const& seq, State const& state, F const& f)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
typename result_of::begin<Sequence const>::type
|
||||
, typename result_of::end<Sequence const>::type>()
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
55
include/boost/fusion/algorithm/iteration/for_each.hpp
Normal file
55
include/boost/fusion/algorithm/iteration/for_each.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FOR_EACH_05052005_1027)
|
||||
#define FUSION_FOR_EACH_05052005_1027
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/detail/for_each.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct for_each
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline void
|
||||
for_each(Sequence& seq, F const& f)
|
||||
{
|
||||
detail::for_each(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline void
|
||||
for_each(Sequence const& seq, F const& f)
|
||||
{
|
||||
detail::for_each(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence const>::type
|
||||
, typename result_of::end<Sequence const>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
19
include/boost/fusion/algorithm/query.hpp
Normal file
19
include/boost/fusion/algorithm/query.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ALGORITHM_QUERY_10022005_0549)
|
||||
#define FUSION_ALGORITHM_QUERY_10022005_0549
|
||||
|
||||
#include <boost/fusion/algorithm/query/all.hpp>
|
||||
#include <boost/fusion/algorithm/query/any.hpp>
|
||||
#include <boost/fusion/algorithm/query/count.hpp>
|
||||
#include <boost/fusion/algorithm/query/count_if.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/fusion/algorithm/query/none.hpp>
|
||||
|
||||
#endif
|
42
include/boost/fusion/algorithm/query/all.hpp
Normal file
42
include/boost/fusion/algorithm/query/all.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ALL_05052005_1238)
|
||||
#define FUSION_ALL_05052005_1238
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/all.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct all
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline bool
|
||||
all(Sequence const& seq, F f)
|
||||
{
|
||||
return detail::all(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
43
include/boost/fusion/algorithm/query/any.hpp
Normal file
43
include/boost/fusion/algorithm/query/any.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
Use, modification and distribution is subject to 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_ANY_05052005_1230)
|
||||
#define FUSION_ANY_05052005_1230
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/any.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct any
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline bool
|
||||
any(Sequence const& seq, F f)
|
||||
{
|
||||
return detail::any(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
46
include/boost/fusion/algorithm/query/count.hpp
Normal file
46
include/boost/fusion/algorithm/query/count.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_COUNT_09162005_0150)
|
||||
#define FUSION_COUNT_09162005_0150
|
||||
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/count_if.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/count.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct count
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline int
|
||||
count(Sequence const& seq, T const& x)
|
||||
{
|
||||
detail::count_compare<T> f(x);
|
||||
return detail::count_if(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
42
include/boost/fusion/algorithm/query/count_if.hpp
Normal file
42
include/boost/fusion/algorithm/query/count_if.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_COUNT_IF_09162005_0137)
|
||||
#define FUSION_COUNT_IF_09162005_0137
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/count_if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct count_if
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline int
|
||||
count_if(Sequence const& seq, F f)
|
||||
{
|
||||
return detail::count_if(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
40
include/boost/fusion/algorithm/query/detail/Attic/none.hpp
Normal file
40
include/boost/fusion/algorithm/query/detail/Attic/none.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_NONE_07062005_1126)
|
||||
#define FUSION_NONE_07062005_1126
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
none(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
none(First const& first, Last const& last, F& f, mpl::false_)
|
||||
{
|
||||
typename result_of::deref<First>::type x = *first;
|
||||
return !f(x) &&
|
||||
detail::none(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
40
include/boost/fusion/algorithm/query/detail/all.hpp
Normal file
40
include/boost/fusion/algorithm/query/detail/all.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ALL_05052005_1237)
|
||||
#define FUSION_ALL_05052005_1237
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
all(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
all(First const& first, Last const& last, F& f, mpl::false_)
|
||||
{
|
||||
typename result_of::deref<First>::type x = *first;
|
||||
return f(x) &&
|
||||
detail::all(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
41
include/boost/fusion/algorithm/query/detail/any.hpp
Normal file
41
include/boost/fusion/algorithm/query/detail/any.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
Use, modification and distribution is subject to 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_ANY_05052005_1229)
|
||||
#define FUSION_ANY_05052005_1229
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
any(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
any(First const& first, Last const& last, F& f, mpl::false_)
|
||||
{
|
||||
typename result_of::deref<First>::type x = *first;
|
||||
return f(x) ||
|
||||
detail::any(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
36
include/boost/fusion/algorithm/query/detail/assoc_find.hpp
Normal file
36
include/boost/fusion/algorithm/query/detail/assoc_find.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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
|
69
include/boost/fusion/algorithm/query/detail/count.hpp
Normal file
69
include/boost/fusion/algorithm/query/detail/count.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_COUNT_09162005_0158)
|
||||
#define FUSION_COUNT_09162005_0158
|
||||
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <bool is_convertible>
|
||||
struct compare_convertible;
|
||||
|
||||
// T1 is convertible to T2 or vice versa
|
||||
template <>
|
||||
struct compare_convertible<true>
|
||||
{
|
||||
template <typename T1, typename T2>
|
||||
static bool
|
||||
call(T1 const& x, T2 const& y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
};
|
||||
|
||||
// T1 is NOT convertible to T2 NOR vice versa
|
||||
template <>
|
||||
struct compare_convertible<false>
|
||||
{
|
||||
template <typename T1, typename T2>
|
||||
static bool
|
||||
call(T1 const&, T2 const&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1>
|
||||
struct count_compare
|
||||
{
|
||||
typedef typename detail::call_param<T1>::type param;
|
||||
count_compare(param x)
|
||||
: x(x) {}
|
||||
|
||||
template <typename T2>
|
||||
bool
|
||||
operator()(T2 const& y)
|
||||
{
|
||||
return
|
||||
compare_convertible<
|
||||
mpl::or_<
|
||||
is_convertible<T1, T2>
|
||||
, is_convertible<T2, T1>
|
||||
>::value
|
||||
>::call(x, y);
|
||||
}
|
||||
|
||||
param x;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
43
include/boost/fusion/algorithm/query/detail/count_if.hpp
Normal file
43
include/boost/fusion/algorithm/query/detail/count_if.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_COUNT_IF_09162005_0141)
|
||||
#define FUSION_COUNT_IF_09162005_0141
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline int
|
||||
count_if(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline int
|
||||
count_if(First const& first, Last const& last, F& f, mpl::false_)
|
||||
{
|
||||
typename result_of::deref<First>::type x = *first;
|
||||
int n =
|
||||
detail::count_if(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
if (f(x))
|
||||
++n;
|
||||
return n;
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
119
include/boost/fusion/algorithm/query/detail/find_if.hpp
Normal file
119
include/boost/fusion/algorithm/query/detail/find_if.hpp
Normal file
@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FIND_IF_05052005_1107)
|
||||
#define FUSION_FIND_IF_05052005_1107
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#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>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename Iterator, typename Pred>
|
||||
struct apply_filter
|
||||
{
|
||||
typedef typename
|
||||
mpl::apply1<
|
||||
Pred
|
||||
, typename result_of::value_of<Iterator>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct main_find_if;
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct recursive_find_if
|
||||
{
|
||||
typedef typename
|
||||
main_find_if<
|
||||
typename result_of::next<First>::type, Last, Pred
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct main_find_if
|
||||
{
|
||||
typedef mpl::or_<
|
||||
result_of::equal_to<First, Last>
|
||||
, apply_filter<First, Pred> >
|
||||
filter;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
filter
|
||||
, mpl::identity<First>
|
||||
, recursive_find_if<First, Last, Pred>
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct static_find_if
|
||||
{
|
||||
typedef typename
|
||||
main_find_if<
|
||||
First
|
||||
, Last
|
||||
, typename mpl::lambda<Pred>::type
|
||||
>::type
|
||||
type;
|
||||
|
||||
template <typename Iterator>
|
||||
static type
|
||||
call(Iterator const& iter, mpl::true_)
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static type
|
||||
call(Iterator const& iter, mpl::false_)
|
||||
{
|
||||
return call(fusion::next(iter));
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static type
|
||||
call(Iterator const& iter)
|
||||
{
|
||||
typedef result_of::equal_to<Iterator, type> found;
|
||||
return call(iter, found());
|
||||
}
|
||||
};
|
||||
|
||||
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
|
40
include/boost/fusion/algorithm/query/detail/none.hpp
Normal file
40
include/boost/fusion/algorithm/query/detail/none.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_NONE_07062005_1126)
|
||||
#define FUSION_NONE_07062005_1126
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
none(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
none(First const& first, Last const& last, F& f, mpl::false_)
|
||||
{
|
||||
typename result_of::deref<First>::type x = *first;
|
||||
return !f(x) &&
|
||||
detail::none(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f
|
||||
, result_of::equal_to<typename result_of::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
76
include/boost/fusion/algorithm/query/find.hpp
Normal file
76
include/boost/fusion/algorithm/query/find.hpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FIND_05052005_1107)
|
||||
#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/support/is_associative.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>
|
||||
{
|
||||
typedef
|
||||
detail::static_seq_find_if<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type
|
||||
, is_same<mpl::_, 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>
|
||||
inline typename
|
||||
lazy_disable_if<
|
||||
is_const<Sequence>
|
||||
, result_of::find<Sequence, T>
|
||||
>::type
|
||||
find(Sequence& seq)
|
||||
{
|
||||
typedef typename result_of::find<Sequence, T>::filter filter;
|
||||
return filter::call(seq);
|
||||
}
|
||||
|
||||
template <typename T, typename Sequence>
|
||||
inline typename result_of::find<Sequence const, T>::type
|
||||
find(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::find<Sequence const, T>::filter filter;
|
||||
return filter::call(seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
70
include/boost/fusion/algorithm/query/find_if.hpp
Normal file
70
include/boost/fusion/algorithm/query/find_if.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FIND_IF_05052005_1108)
|
||||
#define FUSION_FIND_IF_05052005_1108
|
||||
|
||||
#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/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct find_if
|
||||
{
|
||||
typedef typename
|
||||
detail::static_find_if<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type
|
||||
, Pred
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Pred, typename Sequence>
|
||||
inline typename
|
||||
lazy_disable_if<
|
||||
is_const<Sequence>
|
||||
, result_of::find_if<Sequence, Pred>
|
||||
>::type
|
||||
find_if(Sequence& seq)
|
||||
{
|
||||
typedef
|
||||
detail::static_find_if<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type
|
||||
, Pred
|
||||
>
|
||||
filter;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
|
||||
template <typename Pred, typename Sequence>
|
||||
inline typename result_of::find_if<Sequence const, Pred>::type
|
||||
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;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
42
include/boost/fusion/algorithm/query/none.hpp
Normal file
42
include/boost/fusion/algorithm/query/none.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_NONE_07062005_1128)
|
||||
#define FUSION_NONE_07062005_1128
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/none.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct none
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline bool
|
||||
none(Sequence const& seq, F f)
|
||||
{
|
||||
return detail::none(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, result_of::equal_to<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
29
include/boost/fusion/algorithm/transformation.hpp
Normal file
29
include/boost/fusion/algorithm/transformation.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ALGORITHM_TRANSFORMATION_10022005_0551)
|
||||
#define FUSION_ALGORITHM_TRANSFORMATION_10022005_0551
|
||||
|
||||
#include <boost/fusion/algorithm/transformation/clear.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/erase.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/erase_key.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/filter.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/filter_if.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/insert.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/insert_range.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/pop_back.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/pop_front.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_front.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/remove.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/remove_if.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/replace.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/replace_if.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/reverse.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/transform.hpp>
|
||||
|
||||
#endif
|
33
include/boost/fusion/algorithm/transformation/clear.hpp
Normal file
33
include/boost/fusion/algorithm/transformation/clear.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_CLEAR_09172005_1127)
|
||||
#define FUSION_CLEAR_09172005_1127
|
||||
|
||||
#include <boost/fusion/sequence/container/vector/vector10.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct clear
|
||||
{
|
||||
typedef vector0 type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline typename result_of::clear<Sequence const>::type
|
||||
clear(Sequence const& seq)
|
||||
{
|
||||
return vector0();
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REPLACE_08182005_0841)
|
||||
#define FUSION_REPLACE_08182005_0841
|
||||
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <bool is_convertible>
|
||||
struct replacer_helper;
|
||||
|
||||
template <>
|
||||
struct replacer_helper<false>
|
||||
{
|
||||
template <typename U, typename T>
|
||||
static U&
|
||||
call(U& x, T const&, T const&)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct replacer_helper<true>
|
||||
{
|
||||
template <typename U, typename T>
|
||||
static U
|
||||
call(U& x, T const& old_value, T const& new_value)
|
||||
{
|
||||
return (x == old_value) ? new_value : x;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct replacer
|
||||
{
|
||||
replacer(T const& old_value, T const& new_value)
|
||||
: old_value(old_value), new_value(new_value) {}
|
||||
|
||||
template <typename U>
|
||||
struct result
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<is_convertible<T, U>, U, U const&>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename U>
|
||||
typename result<U>::type
|
||||
operator()(U const& x) const
|
||||
{
|
||||
return replacer_helper<is_convertible<T, U>::value>::
|
||||
call(x, old_value, new_value);
|
||||
}
|
||||
|
||||
T old_value;
|
||||
T new_value;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REPLACE_IF_08182005_0946)
|
||||
#define FUSION_REPLACE_IF_08182005_0946
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <bool is_convertible>
|
||||
struct replacer_if_helper;
|
||||
|
||||
template <>
|
||||
struct replacer_if_helper<false>
|
||||
{
|
||||
template <typename U, typename F, typename T>
|
||||
static U&
|
||||
call(U& x, F&, T const&)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct replacer_if_helper<true>
|
||||
{
|
||||
template <typename U, typename F, typename T>
|
||||
static U
|
||||
call(U& x, F& f, T const& new_value)
|
||||
{
|
||||
return f(x) ? new_value : x;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename F, typename T>
|
||||
struct replacer_if
|
||||
{
|
||||
replacer_if(F f, T const& new_value)
|
||||
: f(f), new_value(new_value) {}
|
||||
|
||||
template <typename U>
|
||||
struct result
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<is_convertible<T, U>, U, U const&>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename U>
|
||||
typename result<U>::type
|
||||
operator()(U const& x) const
|
||||
{
|
||||
return replacer_if_helper<is_convertible<T, U>::value>::
|
||||
call(x, f, new_value);
|
||||
}
|
||||
|
||||
F f;
|
||||
T new_value;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
108
include/boost/fusion/algorithm/transformation/erase.hpp
Normal file
108
include/boost/fusion/algorithm/transformation/erase.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ERASE_07232005_0534)
|
||||
#define FUSION_ERASE_07232005_0534
|
||||
|
||||
#include <boost/fusion/sequence/container/vector/vector10.hpp>
|
||||
#include <boost/fusion/sequence/view/joint_view/joint_view.hpp>
|
||||
#include <boost/fusion/sequence/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename First>
|
||||
struct compute_erase_last // put this in detail!!!
|
||||
{
|
||||
typedef typename result_of::end<Sequence>::type seq_last_type;
|
||||
typedef typename convert_iterator<First>::type first_type;
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
result_of::equal_to<first_type, seq_last_type>
|
||||
, first_type
|
||||
, typename result_of::next<first_type>::type
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(First const& first, mpl::false_)
|
||||
{
|
||||
return fusion::next(convert_iterator<First>::call(first));
|
||||
}
|
||||
|
||||
static type
|
||||
call(First const& first, mpl::true_)
|
||||
{
|
||||
return convert_iterator<First>::call(first);
|
||||
}
|
||||
|
||||
static type
|
||||
call(First const& first)
|
||||
{
|
||||
return call(first, result_of::equal_to<first_type, seq_last_type>());
|
||||
}
|
||||
};
|
||||
|
||||
template <
|
||||
typename Sequence
|
||||
, typename First
|
||||
, typename Last = typename compute_erase_last<Sequence, First>::type>
|
||||
struct erase
|
||||
{
|
||||
typedef typename result_of::begin<Sequence>::type seq_first_type;
|
||||
typedef typename result_of::end<Sequence>::type seq_last_type;
|
||||
BOOST_STATIC_ASSERT((!result_of::equal_to<seq_first_type, seq_last_type>::value));
|
||||
|
||||
typedef typename convert_iterator<First>::type first_type;
|
||||
typedef typename convert_iterator<Last>::type last_type;
|
||||
typedef iterator_range<seq_first_type, first_type> left_type;
|
||||
typedef iterator_range<last_type, seq_last_type> right_type;
|
||||
typedef joint_view<left_type, right_type> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename First>
|
||||
typename result_of::erase<Sequence const, First>::type
|
||||
erase(Sequence const& seq, First const& first)
|
||||
{
|
||||
typedef result_of::erase<Sequence const, First> result_of;
|
||||
typedef typename result_of::left_type left_type;
|
||||
typedef typename result_of::right_type right_type;
|
||||
typedef typename result_of::type result_type;
|
||||
|
||||
left_type left(
|
||||
fusion::begin(seq)
|
||||
, convert_iterator<First>::call(first));
|
||||
right_type right(
|
||||
fusion::result_of::compute_erase_last<Sequence const, First>::call(first)
|
||||
, fusion::end(seq));
|
||||
return result_type(left, right);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename First, typename Last>
|
||||
typename result_of::erase<Sequence const, First, Last>::type
|
||||
erase(Sequence const& seq, First const& first, Last const& last)
|
||||
{
|
||||
typedef result_of::erase<Sequence const, First, Last> result_of;
|
||||
typedef typename result_of::left_type left_type;
|
||||
typedef typename result_of::right_type right_type;
|
||||
typedef typename result_of::type result_type;
|
||||
|
||||
left_type left(fusion::begin(seq), first);
|
||||
right_type right(last, fusion::end(seq));
|
||||
return result_type(left, right);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
38
include/boost/fusion/algorithm/transformation/erase_key.hpp
Normal file
38
include/boost/fusion/algorithm/transformation/erase_key.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_ERASE_KEY_10022005_1851)
|
||||
#define FUSION_ERASE_KEY_10022005_1851
|
||||
|
||||
#include <boost/fusion/algorithm/query/detail/assoc_find.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/erase.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Key>
|
||||
struct erase_key
|
||||
{
|
||||
typedef detail::assoc_find<Sequence, Key> filter;
|
||||
typedef typename erase<Sequence, typename filter::type>::type type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Key, typename Sequence>
|
||||
inline typename result_of::erase_key<Sequence const, Key>::type
|
||||
erase_key(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::erase_key<Sequence const, Key>::filter filter;
|
||||
return erase(seq, filter::call(seq));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
35
include/boost/fusion/algorithm/transformation/filter.hpp
Normal file
35
include/boost/fusion/algorithm/transformation/filter.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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_FILTER_02122005_1839)
|
||||
#define FUSION_FILTER_02122005_1839
|
||||
|
||||
#include <boost/fusion/sequence/view/filter_view/filter_view.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct filter
|
||||
{
|
||||
typedef filter_view<Sequence, is_same<mpl::_, T> > type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename Sequence>
|
||||
inline typename result_of::filter<Sequence const, T>::type
|
||||
filter(Sequence const& seq)
|
||||
{
|
||||
return filter_view<const Sequence, is_same<mpl::_, T> >(seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
33
include/boost/fusion/algorithm/transformation/filter_if.hpp
Normal file
33
include/boost/fusion/algorithm/transformation/filter_if.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_FILTER_IF_07172005_0818)
|
||||
#define FUSION_FILTER_IF_07172005_0818
|
||||
|
||||
#include <boost/fusion/sequence/view/filter_view/filter_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct filter_if
|
||||
{
|
||||
typedef filter_view<Sequence, Pred> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Pred, typename Sequence>
|
||||
inline typename result_of::filter_if<Sequence const, Pred>::type
|
||||
filter_if(Sequence const& seq)
|
||||
{
|
||||
return filter_view<Sequence const, Pred>(seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
63
include/boost/fusion/algorithm/transformation/insert.hpp
Normal file
63
include/boost/fusion/algorithm/transformation/insert.hpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_INSERT_07222005_0730)
|
||||
#define FUSION_INSERT_07222005_0730
|
||||
|
||||
#include <boost/fusion/sequence/container/vector/vector10.hpp>
|
||||
#include <boost/fusion/sequence/view/joint_view/joint_view.hpp>
|
||||
#include <boost/fusion/sequence/view/single_view/single_view.hpp>
|
||||
#include <boost/fusion/sequence/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
struct insert
|
||||
{
|
||||
typedef typename detail::as_fusion_element<T>::type element_type;
|
||||
typedef typename convert_iterator<Position>::type pos_type;
|
||||
typedef typename result_of::begin<Sequence>::type first_type;
|
||||
typedef typename result_of::end<Sequence>::type last_type;
|
||||
|
||||
typedef iterator_range<first_type, pos_type> left_type;
|
||||
typedef iterator_range<pos_type, last_type> right_type;
|
||||
typedef single_view<element_type> single_view;
|
||||
typedef joint_view<left_type, single_view const> left_insert_type;
|
||||
typedef joint_view<left_insert_type, right_type> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
inline typename result_of::insert<
|
||||
Sequence const, Position, T>::type
|
||||
insert(Sequence const& seq, Position const& pos, T const& x)
|
||||
{
|
||||
typedef result_of::insert<
|
||||
Sequence const, Position, T>
|
||||
result_of;
|
||||
typedef typename result_of::left_type left_type;
|
||||
typedef typename result_of::right_type right_type;
|
||||
typedef typename result_of::single_view single_view;
|
||||
typedef typename result_of::left_insert_type left_insert_type;
|
||||
typedef typename result_of::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), convert_iterator<Position>::call(pos));
|
||||
right_type right(convert_iterator<Position>::call(pos), fusion::end(seq));
|
||||
single_view insert(x);
|
||||
left_insert_type left_insert(left, insert);
|
||||
return result(left_insert, right);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_INSERT_RANGE_009172005_1147)
|
||||
#define FUSION_INSERT_RANGE_009172005_1147
|
||||
|
||||
#include <boost/fusion/sequence/container/vector/vector10.hpp>
|
||||
#include <boost/fusion/sequence/view/joint_view/joint_view.hpp>
|
||||
#include <boost/fusion/sequence/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Position, typename Range>
|
||||
struct insert_range
|
||||
{
|
||||
typedef typename convert_iterator<Position>::type pos_type;
|
||||
typedef typename result_of::begin<Sequence>::type first_type;
|
||||
typedef typename result_of::end<Sequence>::type last_type;
|
||||
|
||||
typedef iterator_range<first_type, pos_type> left_type;
|
||||
typedef iterator_range<pos_type, last_type> right_type;
|
||||
typedef joint_view<left_type, Range> left_insert_type;
|
||||
typedef joint_view<left_insert_type, right_type> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Position, typename Range>
|
||||
inline typename result_of::insert_range<Sequence const, Position, Range const>::type
|
||||
insert_range(Sequence const& seq, Position const& pos, Range const& range)
|
||||
{
|
||||
typedef result_of::insert_range<Sequence const, Position, Range const> result_of;
|
||||
typedef typename result_of::left_type left_type;
|
||||
typedef typename result_of::right_type right_type;
|
||||
typedef typename result_of::left_insert_type left_insert_type;
|
||||
typedef typename result_of::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), convert_iterator<Position>::call(pos));
|
||||
right_type right(convert_iterator<Position>::call(pos), fusion::end(seq));
|
||||
left_insert_type left_insert(left, range);
|
||||
return result(left_insert, right);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
34
include/boost/fusion/algorithm/transformation/join.hpp
Normal file
34
include/boost/fusion/algorithm/transformation/join.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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_JOIN_200601222109)
|
||||
#define FUSION_JOIN_200601222109
|
||||
|
||||
#include <boost/fusion/sequence/view/joint_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template<typename LhSequence, typename RhSequence>
|
||||
struct join
|
||||
{
|
||||
typedef joint_view<LhSequence, RhSequence> type;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename LhSequence, typename RhSequence>
|
||||
inline typename result_of::join<LhSequence const, RhSequence const>::type
|
||||
join(LhSequence const& lhs, RhSequence const& rhs)
|
||||
{
|
||||
return typename result_of::join<LhSequence const, RhSequence const>::type(
|
||||
lhs, rhs);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
44
include/boost/fusion/algorithm/transformation/pop_back.hpp
Normal file
44
include/boost/fusion/algorithm/transformation/pop_back.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_POP_BACK_09172005_1038)
|
||||
#define FUSION_POP_BACK_09172005_1038
|
||||
|
||||
#include <boost/fusion/sequence/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct pop_back
|
||||
{
|
||||
typedef
|
||||
iterator_range<
|
||||
typename begin<Sequence>::type
|
||||
, typename prior<
|
||||
typename end<Sequence>::type
|
||||
>::type
|
||||
>
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline typename result_of::pop_back<Sequence const>::type
|
||||
pop_back(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::pop_back<Sequence const>::type result;
|
||||
return result(fusion::begin(seq), fusion::prior(fusion::end(seq)));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
44
include/boost/fusion/algorithm/transformation/pop_front.hpp
Normal file
44
include/boost/fusion/algorithm/transformation/pop_front.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_POP_FRONT_09172005_1115)
|
||||
#define FUSION_POP_FRONT_09172005_1115
|
||||
|
||||
#include <boost/fusion/sequence/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct pop_front
|
||||
{
|
||||
typedef
|
||||
iterator_range<
|
||||
typename next<
|
||||
typename begin<Sequence>::type
|
||||
>::type
|
||||
, typename end<Sequence>::type
|
||||
>
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline typename result_of::pop_front<Sequence const>::type
|
||||
pop_front(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::pop_front<Sequence const>::type result;
|
||||
return result(fusion::next(fusion::begin(seq)), fusion::end(seq));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
40
include/boost/fusion/algorithm/transformation/push_back.hpp
Normal file
40
include/boost/fusion/algorithm/transformation/push_back.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_PUSH_BACK_07162005_0235)
|
||||
#define FUSION_PUSH_BACK_07162005_0235
|
||||
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/view/joint_view/joint_view.hpp>
|
||||
#include <boost/fusion/sequence/view/single_view/single_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct push_back
|
||||
{
|
||||
typedef single_view<typename detail::as_fusion_element<T>::type> single_view;
|
||||
typedef joint_view<Sequence, single_view const> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename result_of::push_back<Sequence const, T>::type
|
||||
push_back(Sequence const& seq, T const& x)
|
||||
{
|
||||
typedef typename result_of::push_back<Sequence const, T> push_back;
|
||||
typedef typename push_back::single_view single_view;
|
||||
typedef typename push_back::type result;
|
||||
single_view x_(x);
|
||||
return result(seq, x_);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
40
include/boost/fusion/algorithm/transformation/push_front.hpp
Normal file
40
include/boost/fusion/algorithm/transformation/push_front.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_PUSH_FRONT_07162005_0749)
|
||||
#define FUSION_PUSH_FRONT_07162005_0749
|
||||
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/fusion/sequence/view/joint_view/joint_view.hpp>
|
||||
#include <boost/fusion/sequence/view/single_view/single_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct push_front
|
||||
{
|
||||
typedef single_view<typename detail::as_fusion_element<T>::type> single_view;
|
||||
typedef joint_view<single_view const, Sequence> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename result_of::push_front<Sequence const, T>::type
|
||||
push_front(Sequence const& seq, T const& x)
|
||||
{
|
||||
typedef typename result_of::push_front<Sequence const, T> push_front;
|
||||
typedef typename push_front::single_view single_view;
|
||||
typedef typename push_front::type result;
|
||||
single_view x_(x);
|
||||
return result(x_, seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
36
include/boost/fusion/algorithm/transformation/remove.hpp
Normal file
36
include/boost/fusion/algorithm/transformation/remove.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REMOVE_07162005_0818)
|
||||
#define FUSION_REMOVE_07162005_0818
|
||||
|
||||
#include <boost/fusion/sequence/view/filter_view/filter_view.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct remove
|
||||
{
|
||||
typedef filter_view<Sequence, mpl::not_<is_same<mpl::_, T> > > type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename Sequence>
|
||||
inline typename result_of::remove<Sequence const, T>::type
|
||||
remove(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::remove<Sequence const, T>::type result_type;
|
||||
return result_type(seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
36
include/boost/fusion/algorithm/transformation/remove_if.hpp
Normal file
36
include/boost/fusion/algorithm/transformation/remove_if.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REMOVE_IF_07162005_0818)
|
||||
#define FUSION_REMOVE_IF_07162005_0818
|
||||
|
||||
#include <boost/fusion/sequence/view/filter_view/filter_view.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct remove_if
|
||||
{
|
||||
typedef filter_view<Sequence, mpl::not_<Pred> > type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Pred, typename Sequence>
|
||||
inline typename result_of::remove_if<Sequence const, Pred>::type
|
||||
remove_if(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::remove_if<Sequence const, Pred>::type result_type;
|
||||
return result_type(seq);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
36
include/boost/fusion/algorithm/transformation/replace.hpp
Normal file
36
include/boost/fusion/algorithm/transformation/replace.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REPLACE_08182005_0830)
|
||||
#define FUSION_REPLACE_08182005_0830
|
||||
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/detail/replace.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct replace
|
||||
{
|
||||
typedef transform_view<Sequence, detail::replacer<T> > type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename result_of::replace<Sequence const, T>::type
|
||||
replace(Sequence const& seq, T const& old_value, T const& new_value)
|
||||
{
|
||||
typedef typename result_of::replace<Sequence const, T>::type result;
|
||||
detail::replacer<T> f(old_value, new_value);
|
||||
return result(seq, f);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
38
include/boost/fusion/algorithm/transformation/replace_if.hpp
Normal file
38
include/boost/fusion/algorithm/transformation/replace_if.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REPLACE_IF_08182005_0939)
|
||||
#define FUSION_REPLACE_IF_08182005_0939
|
||||
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/detail/replace_if.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F, typename T>
|
||||
struct replace_if
|
||||
{
|
||||
typedef transform_view<Sequence, detail::replacer_if<F, T> > type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F, typename T>
|
||||
inline typename result_of::replace_if<Sequence const, F, T>::type
|
||||
replace_if(Sequence const& seq, F pred, T const& new_value)
|
||||
{
|
||||
typedef typename result_of::replace_if<Sequence const, F, T>::type result;
|
||||
detail::replacer_if<F, T> f(pred, new_value);
|
||||
return result(seq, f);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
33
include/boost/fusion/algorithm/transformation/reverse.hpp
Normal file
33
include/boost/fusion/algorithm/transformation/reverse.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_REVERSE_07212005_1230)
|
||||
#define FUSION_REVERSE_07212005_1230
|
||||
|
||||
#include <boost/fusion/sequence/view/reverse_view/reverse_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct reverse
|
||||
{
|
||||
typedef reverse_view<Sequence> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline reverse_view<Sequence const>
|
||||
reverse(Sequence const& view)
|
||||
{
|
||||
return reverse_view<Sequence const>(view);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
48
include/boost/fusion/algorithm/transformation/transform.hpp
Normal file
48
include/boost/fusion/algorithm/transformation/transform.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_TRANSFORM_07052005_1057)
|
||||
#define FUSION_TRANSFORM_07052005_1057
|
||||
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence1, typename Sequence2, typename F = void_>
|
||||
struct transform
|
||||
{
|
||||
typedef transform_view<Sequence1, Sequence2, F> type;
|
||||
};
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
struct transform<Sequence, F>
|
||||
{
|
||||
typedef transform_view<Sequence, F> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline typename result_of::transform<Sequence const, F>::type
|
||||
transform(Sequence const& seq, F f)
|
||||
{
|
||||
return transform_view<Sequence const, F>(seq, f);
|
||||
}
|
||||
|
||||
template <typename Sequence1, typename Sequence2, typename F>
|
||||
inline typename result_of::transform<Sequence1 const, Sequence2 const, F>::type
|
||||
transform(Sequence1 const& seq1, Sequence2 const& seq2, F f)
|
||||
{
|
||||
return transform_view<Sequence1 const, Sequence2 const, F>(seq1, seq2, f);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
80
include/boost/fusion/algorithm/transformation/zip.hpp
Normal file
80
include/boost/fusion/algorithm/transformation/zip.hpp
Normal file
@ -0,0 +1,80 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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)
|
||||
==============================================================================*/
|
||||
#ifndef BOOST_PP_IS_ITERATING
|
||||
#if !defined(FUSION_ZIP_HPP_20060125_2058)
|
||||
#define FUSION_ZIP_HPP_20060125_2058
|
||||
|
||||
#include <boost/fusion/sequence/view/zip_view.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/container/vector.hpp>
|
||||
#include <boost/fusion/sequence/conversion/as_vector.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/transform.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
|
||||
#if !defined(FUSION_MAX_ZIP_SEQUENCES)
|
||||
#define FUSION_MAX_ZIP_SEQUENCES 10
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct void_;
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(FUSION_MAX_ZIP_SEQUENCES), typename T, fusion::void_)>
|
||||
struct zip;
|
||||
}
|
||||
|
||||
#define BOOST_PP_FILENAME_1 \
|
||||
<boost/fusion/algorithm/transformation/zip.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (2, FUSION_MAX_ZIP_SEQUENCES)
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define ZIP_ITERATION BOOST_PP_ITERATION()
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, typename T) >
|
||||
struct zip< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, T) >
|
||||
{
|
||||
typedef mpl::vector< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, T) > sequences;
|
||||
typedef typename mpl::transform<sequences, add_reference<mpl::_> >::type ref_params;
|
||||
typedef zip_view<typename result_of::as_vector<ref_params>::type> type;
|
||||
};
|
||||
}
|
||||
|
||||
#define FUSION_REF_PARAM(z, n, data) const T ## n&
|
||||
|
||||
template<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, typename T)>
|
||||
inline typename result_of::zip<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, const T)>::type
|
||||
zip(BOOST_PP_ENUM_BINARY_PARAMS(ZIP_ITERATION, T, const& t))
|
||||
{
|
||||
fusion::vector<BOOST_PP_ENUM(ZIP_ITERATION, FUSION_REF_PARAM, _)> seqs(
|
||||
BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, t));
|
||||
return typename result_of::zip<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, const T)>::type(
|
||||
seqs);
|
||||
}
|
||||
|
||||
#undef FUSION_REF_PARAM
|
||||
#undef ZIP_ITERATION
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user