1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef BOOST_ALGORITHM_IS_PERMUTATION14_HPP
- #define BOOST_ALGORITHM_IS_PERMUTATION14_HPP
- #include <utility> // for std::pair
- #include <functional> // for std::equal_to
- #include <iterator>
- #include <boost/config.hpp>
- #include <boost/algorithm/cxx11/is_permutation.hpp>
- #include <boost/algorithm/cxx14/mismatch.hpp>
- namespace boost { namespace algorithm {
- template< class ForwardIterator1, class ForwardIterator2 >
- bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
- ForwardIterator2 first2, ForwardIterator2 last2 )
- {
- std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
- ( first1, last1, first2, last2 );
- if ( eq.first == last1 && eq.second == last2)
- return true;
- return boost::algorithm::detail::is_permutation_tag (
- eq.first, last1, eq.second, last2,
- std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (),
- typename std::iterator_traits<ForwardIterator1>::iterator_category (),
- typename std::iterator_traits<ForwardIterator2>::iterator_category ());
- }
- template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
- bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
- ForwardIterator2 first2, ForwardIterator2 last2,
- BinaryPredicate pred )
- {
- std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
- ( first1, last1, first2, last2, pred );
- if ( eq.first == last1 && eq.second == last2)
- return true;
- return boost::algorithm::detail::is_permutation_tag (
- first1, last1, first2, last2, pred,
- typename std::iterator_traits<ForwardIterator1>::iterator_category (),
- typename std::iterator_traits<ForwardIterator2>::iterator_category ());
- }
- }}
- #endif
|