forked from boostorg/fusion
Initial move from Spirit CVS
[SVN r34896]
This commit is contained in:
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
|
||||
|
Reference in New Issue
Block a user