/Src/Dependencies/Boost/boost/fusion/algorithm/query/detail/count.hpp

http://hadesmem.googlecode.com/ · C++ Header · 78 lines · 59 code · 11 blank · 8 comment · 1 complexity · d779fcc8838f6f23a27d094a289d7c3e MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_COUNT_09162005_0158)
  7. #define FUSION_COUNT_09162005_0158
  8. #include <boost/config.hpp>
  9. #include <boost/mpl/or.hpp>
  10. #include <boost/type_traits/is_convertible.hpp>
  11. #include <boost/fusion/support/detail/access.hpp>
  12. #if defined (BOOST_MSVC)
  13. # pragma warning(push)
  14. # pragma warning (disable: 4512) // assignment operator could not be generated.
  15. #endif
  16. namespace boost { namespace fusion { namespace detail
  17. {
  18. template <bool is_convertible>
  19. struct compare_convertible;
  20. // T1 is convertible to T2 or vice versa
  21. template <>
  22. struct compare_convertible<true>
  23. {
  24. template <typename T1, typename T2>
  25. static bool
  26. call(T1 const& x, T2 const& y)
  27. {
  28. return x == y;
  29. }
  30. };
  31. // T1 is NOT convertible to T2 NOR vice versa
  32. template <>
  33. struct compare_convertible<false>
  34. {
  35. template <typename T1, typename T2>
  36. static bool
  37. call(T1 const&, T2 const&)
  38. {
  39. return false;
  40. }
  41. };
  42. template <typename T1>
  43. struct count_compare
  44. {
  45. typedef typename detail::call_param<T1>::type param;
  46. count_compare(param in_x)
  47. : x(in_x) {}
  48. template <typename T2>
  49. bool
  50. operator()(T2 const& y)
  51. {
  52. return
  53. compare_convertible<
  54. mpl::or_<
  55. is_convertible<T1, T2>
  56. , is_convertible<T2, T1>
  57. >::value
  58. >::call(x, y);
  59. }
  60. param x;
  61. };
  62. }}}
  63. #if defined (BOOST_MSVC)
  64. # pragma warning(pop)
  65. #endif
  66. #endif