1 | |
---|---|

2 | #ifndef BOOST_MPL_EQUAL_HPP_INCLUDED |

3 | #define BOOST_MPL_EQUAL_HPP_INCLUDED |

4 | |

5 | // Copyright Aleksey Gurtovoy 2000-2004 |

6 | // |

7 | // Distributed under the Boost Software License, Version 1.0. |

8 | // (See accompanying file LICENSE_1_0.txt or copy at |

9 | // http://www.boost.org/LICENSE_1_0.txt) |

10 | // |

11 | // See http://www.boost.org/libs/mpl for documentation. |

12 | |

13 | // $Id$ |

14 | // $Date$ |

15 | // $Revision$ |

16 | |

17 | #include <boost/mpl/aux_/iter_fold_if_impl.hpp> |

18 | #include <boost/mpl/aux_/iter_apply.hpp> |

19 | #include <boost/mpl/and.hpp> |

20 | #include <boost/mpl/not.hpp> |

21 | #include <boost/mpl/begin_end.hpp> |

22 | #include <boost/mpl/next.hpp> |

23 | #include <boost/mpl/always.hpp> |

24 | #include <boost/mpl/bool.hpp> |

25 | #include <boost/mpl/lambda.hpp> |

26 | #include <boost/mpl/bind.hpp> |

27 | #include <boost/mpl/apply.hpp> |

28 | #include <boost/mpl/void.hpp> |

29 | #include <boost/mpl/aux_/na_spec.hpp> |

30 | #include <boost/mpl/aux_/lambda_support.hpp> |

31 | #include <boost/mpl/aux_/msvc_eti_base.hpp> |

32 | |

33 | #include <boost/type_traits/is_same.hpp> |

34 | |

35 | namespace boost { namespace mpl { |

36 | |

37 | namespace aux { |

38 | |

39 | template< |

40 | typename Predicate |

41 | , typename LastIterator1 |

42 | , typename LastIterator2 |

43 | > |

44 | struct equal_pred |

45 | { |

46 | template< |

47 | typename Iterator2 |

48 | , typename Iterator1 |

49 | > |

50 | struct apply |

51 | { |

52 | typedef typename and_< |

53 | not_< is_same<Iterator1,LastIterator1> > |

54 | , not_< is_same<Iterator2,LastIterator2> > |

55 | , aux::iter_apply2<Predicate,Iterator1,Iterator2> |

56 | >::type type; |

57 | }; |

58 | }; |

59 | |

60 | template< |

61 | typename Sequence1 |

62 | , typename Sequence2 |

63 | , typename Predicate |

64 | > |

65 | struct equal_impl |

66 | { |

67 | typedef typename begin<Sequence1>::type first1_; |

68 | typedef typename begin<Sequence2>::type first2_; |

69 | typedef typename end<Sequence1>::type last1_; |

70 | typedef typename end<Sequence2>::type last2_; |

71 | |

72 | typedef aux::iter_fold_if_impl< |

73 | first1_ |

74 | , first2_ |

75 | , next<> |

76 | , protect< aux::equal_pred<Predicate,last1_,last2_> > |

77 | , void_ |

78 | , always<false_> |

79 | > fold_; |

80 | |

81 | typedef typename fold_::iterator iter1_; |

82 | typedef typename fold_::state iter2_; |

83 | typedef and_< |

84 | is_same<iter1_,last1_> |

85 | , is_same<iter2_,last2_> |

86 | > result_; |

87 | |

88 | typedef typename result_::type type; |

89 | }; |

90 | |

91 | |

92 | } // namespace aux |

93 | |

94 | |

95 | template< |

96 | typename BOOST_MPL_AUX_NA_PARAM(Sequence1) |

97 | , typename BOOST_MPL_AUX_NA_PARAM(Sequence2) |

98 | , typename Predicate = is_same<_,_> |

99 | > |

100 | struct equal |

101 | : aux::msvc_eti_base< |

102 | typename aux::equal_impl<Sequence1,Sequence2,Predicate>::type |

103 | >::type |

104 | { |

105 | BOOST_MPL_AUX_LAMBDA_SUPPORT(2,equal,(Sequence1,Sequence2)) |

106 | }; |

107 | |

108 | BOOST_MPL_AUX_NA_SPEC(2, equal) |

109 | |

110 | }} |

111 | |

112 | #endif // BOOST_MPL_EQUAL_HPP_INCLUDED |

113 |