2006-08-16 16:50:52 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2001-2006 Joel de Guzman
|
|
|
|
|
2007-03-02 10:44:14 +00:00
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
2006-08-16 16:50:52 +00:00
|
|
|
==============================================================================*/
|
|
|
|
#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
|
|
|
|
|