equal.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef BOOST_MPL_EQUAL_HPP_INCLUDED
  2. #define BOOST_MPL_EQUAL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/aux_/iter_fold_if_impl.hpp>
  14. #include <boost/mpl/aux_/iter_apply.hpp>
  15. #include <boost/mpl/and.hpp>
  16. #include <boost/mpl/not.hpp>
  17. #include <boost/mpl/begin_end.hpp>
  18. #include <boost/mpl/next.hpp>
  19. #include <boost/mpl/always.hpp>
  20. #include <boost/mpl/bool.hpp>
  21. #include <boost/mpl/lambda.hpp>
  22. #include <boost/mpl/bind.hpp>
  23. #include <boost/mpl/apply.hpp>
  24. #include <boost/mpl/void.hpp>
  25. #include <boost/mpl/aux_/na_spec.hpp>
  26. #include <boost/mpl/aux_/lambda_support.hpp>
  27. #include <boost/mpl/aux_/msvc_eti_base.hpp>
  28. #include <boost/type_traits/is_same.hpp>
  29. namespace boost { namespace mpl {
  30. namespace aux {
  31. template<
  32. typename Predicate
  33. , typename LastIterator1
  34. , typename LastIterator2
  35. >
  36. struct equal_pred
  37. {
  38. template<
  39. typename Iterator2
  40. , typename Iterator1
  41. >
  42. struct apply
  43. {
  44. typedef typename and_<
  45. not_< is_same<Iterator1,LastIterator1> >
  46. , not_< is_same<Iterator2,LastIterator2> >
  47. , aux::iter_apply2<Predicate,Iterator1,Iterator2>
  48. >::type type;
  49. };
  50. };
  51. template<
  52. typename Sequence1
  53. , typename Sequence2
  54. , typename Predicate
  55. >
  56. struct equal_impl
  57. {
  58. typedef typename begin<Sequence1>::type first1_;
  59. typedef typename begin<Sequence2>::type first2_;
  60. typedef typename end<Sequence1>::type last1_;
  61. typedef typename end<Sequence2>::type last2_;
  62. typedef aux::iter_fold_if_impl<
  63. first1_
  64. , first2_
  65. , next<>
  66. , protect< aux::equal_pred<Predicate,last1_,last2_> >
  67. , void_
  68. , always<false_>
  69. > fold_;
  70. typedef typename fold_::iterator iter1_;
  71. typedef typename fold_::state iter2_;
  72. typedef and_<
  73. is_same<iter1_,last1_>
  74. , is_same<iter2_,last2_>
  75. > result_;
  76. typedef typename result_::type type;
  77. };
  78. } // namespace aux
  79. template<
  80. typename BOOST_MPL_AUX_NA_PARAM(Sequence1)
  81. , typename BOOST_MPL_AUX_NA_PARAM(Sequence2)
  82. , typename Predicate = is_same<_,_>
  83. >
  84. struct equal
  85. : aux::msvc_eti_base<
  86. typename aux::equal_impl<Sequence1,Sequence2,Predicate>::type
  87. >::type
  88. {
  89. BOOST_MPL_AUX_LAMBDA_SUPPORT(2,equal,(Sequence1,Sequence2))
  90. };
  91. BOOST_MPL_AUX_NA_SPEC(2, equal)
  92. }}
  93. #endif // BOOST_MPL_EQUAL_HPP_INCLUDED