File indexing completed on 2025-01-18 09:28:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ALGORITHM_EQUAL_HPP
0013 #define BOOST_ALGORITHM_EQUAL_HPP
0014
0015 #include <iterator>
0016
0017 #include <boost/config.hpp>
0018
0019 namespace boost { namespace algorithm {
0020
0021 namespace detail {
0022
0023 template <class T1, class T2>
0024 struct eq {
0025 BOOST_CONSTEXPR bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
0026 };
0027
0028 template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
0029 BOOST_CXX14_CONSTEXPR
0030 bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
0031 RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
0032 std::random_access_iterator_tag, std::random_access_iterator_tag )
0033 {
0034
0035 if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
0036 return false;
0037
0038
0039 for (; first1 != last1; ++first1, ++first2)
0040 if (!pred(*first1, *first2))
0041 return false;
0042 return true;
0043 }
0044
0045 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
0046 BOOST_CXX14_CONSTEXPR
0047 bool equal ( InputIterator1 first1, InputIterator1 last1,
0048 InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
0049 std::input_iterator_tag, std::input_iterator_tag )
0050 {
0051 for (; first1 != last1 && first2 != last2; ++first1, ++first2 )
0052 if ( !pred(*first1, *first2 ))
0053 return false;
0054
0055 return first1 == last1 && first2 == last2;
0056 }
0057 }
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
0070 BOOST_CXX14_CONSTEXPR
0071 bool equal ( InputIterator1 first1, InputIterator1 last1,
0072 InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred )
0073 {
0074 return boost::algorithm::detail::equal (
0075 first1, last1, first2, last2, pred,
0076 typename std::iterator_traits<InputIterator1>::iterator_category (),
0077 typename std::iterator_traits<InputIterator2>::iterator_category ());
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 template <class InputIterator1, class InputIterator2>
0089 BOOST_CXX14_CONSTEXPR
0090 bool equal ( InputIterator1 first1, InputIterator1 last1,
0091 InputIterator2 first2, InputIterator2 last2 )
0092 {
0093 return boost::algorithm::detail::equal (
0094 first1, last1, first2, last2,
0095 boost::algorithm::detail::eq<
0096 typename std::iterator_traits<InputIterator1>::value_type,
0097 typename std::iterator_traits<InputIterator2>::value_type> (),
0098 typename std::iterator_traits<InputIterator1>::iterator_category (),
0099 typename std::iterator_traits<InputIterator2>::iterator_category ());
0100 }
0101
0102
0103
0104 }}
0105
0106 #endif