count_if.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2007 Dan Marsden
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(BOOST_FUSION_COUNT_IF_09162005_0137)
  8. #define BOOST_FUSION_COUNT_IF_09162005_0137
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/algorithm/query/detail/count_if.hpp>
  11. #include <boost/fusion/support/category_of.hpp>
  12. #include <boost/fusion/support/is_sequence.hpp>
  13. #include <boost/utility/enable_if.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. namespace result_of
  17. {
  18. template <typename Sequence, typename F>
  19. struct count_if
  20. {
  21. typedef int type;
  22. };
  23. }
  24. template <typename Sequence, typename F>
  25. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  26. inline typename
  27. enable_if<
  28. traits::is_sequence<Sequence>
  29. , int
  30. >::type
  31. count_if(Sequence const& seq, F f)
  32. {
  33. return detail::count_if(
  34. seq, f, typename traits::category_of<Sequence>::type());
  35. }
  36. }}
  37. #endif