forked from boostorg/algorithm
Minor merging; removing tabs from source files
[SVN r86323]
This commit is contained in:
@ -12,41 +12,41 @@
|
|||||||
#ifndef BOOST_ALGORITHM_EQUAL_HPP
|
#ifndef BOOST_ALGORITHM_EQUAL_HPP
|
||||||
#define BOOST_ALGORITHM_EQUAL_HPP
|
#define BOOST_ALGORITHM_EQUAL_HPP
|
||||||
|
|
||||||
#include <algorithm> // for std::equal
|
#include <algorithm> // for std::equal
|
||||||
#include <functional> // for std::equal_to
|
#include <functional> // for std::equal_to
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct eq : public std::binary_function<T1, T2, bool> {
|
struct eq : public std::binary_function<T1, T2, bool> {
|
||||||
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
|
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
|
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
|
||||||
bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||||
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
|
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
|
||||||
std::random_access_iterator_tag, std::random_access_iterator_tag )
|
std::random_access_iterator_tag, std::random_access_iterator_tag )
|
||||||
{
|
{
|
||||||
// Random-access iterators let is check the sizes in constant time
|
// Random-access iterators let is check the sizes in constant time
|
||||||
if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
|
if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
|
||||||
return false;
|
return false;
|
||||||
// If we know that the sequences are the same size, the original version is fine
|
// If we know that the sequences are the same size, the original version is fine
|
||||||
return std::equal ( first1, last1, first2, pred );
|
return std::equal ( first1, last1, first2, pred );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
|
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
|
||||||
std::input_iterator_tag, std::input_iterator_tag )
|
std::input_iterator_tag, std::input_iterator_tag )
|
||||||
{
|
{
|
||||||
for (; first1 != last1 && first2 != last2; ++first1, ++first2 )
|
for (; first1 != last1 && first2 != last2; ++first1, ++first2 )
|
||||||
if ( !pred(*first1, *first2 ))
|
if ( !pred(*first1, *first2 ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return first1 == last1 && first2 == last2;
|
return first1 == last1 && first2 == last2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
|
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
|
||||||
@ -63,10 +63,10 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
|||||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred )
|
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred )
|
||||||
{
|
{
|
||||||
return boost::algorithm::detail::equal (
|
return boost::algorithm::detail::equal (
|
||||||
first1, last1, first2, last2, pred,
|
first1, last1, first2, last2, pred,
|
||||||
typename std::iterator_traits<InputIterator1>::iterator_category (),
|
typename std::iterator_traits<InputIterator1>::iterator_category (),
|
||||||
typename std::iterator_traits<InputIterator2>::iterator_category ());
|
typename std::iterator_traits<InputIterator2>::iterator_category ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
|
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
|
||||||
@ -81,16 +81,16 @@ template <class InputIterator1, class InputIterator2>
|
|||||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2 )
|
InputIterator2 first2, InputIterator2 last2 )
|
||||||
{
|
{
|
||||||
return boost::algorithm::detail::equal (
|
return boost::algorithm::detail::equal (
|
||||||
first1, last1, first2, last2,
|
first1, last1, first2, last2,
|
||||||
boost::algorithm::detail::eq<
|
boost::algorithm::detail::eq<
|
||||||
typename std::iterator_traits<InputIterator1>::value_type,
|
typename std::iterator_traits<InputIterator1>::value_type,
|
||||||
typename std::iterator_traits<InputIterator2>::value_type> (),
|
typename std::iterator_traits<InputIterator2>::value_type> (),
|
||||||
typename std::iterator_traits<InputIterator1>::iterator_category (),
|
typename std::iterator_traits<InputIterator1>::iterator_category (),
|
||||||
typename std::iterator_traits<InputIterator2>::iterator_category ());
|
typename std::iterator_traits<InputIterator2>::iterator_category ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are already range-based versions of these.
|
// There are already range-based versions of these.
|
||||||
|
|
||||||
}} // namespace boost and algorithm
|
}} // namespace boost and algorithm
|
||||||
|
|
||||||
|
@ -12,13 +12,11 @@
|
|||||||
#ifndef BOOST_ALGORITHM_MISMATCH_HPP
|
#ifndef BOOST_ALGORITHM_MISMATCH_HPP
|
||||||
#define BOOST_ALGORITHM_MISMATCH_HPP
|
#define BOOST_ALGORITHM_MISMATCH_HPP
|
||||||
|
|
||||||
#include <algorithm> // for std::mismatch
|
#include <algorithm> // for std::mismatch
|
||||||
#include <utility> // for std::pair
|
#include <utility> // for std::pair
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
|
||||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
|
||||||
|
|
||||||
/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
|
/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
|
||||||
/// InputIterator2 first2, InputIterator2 last2,
|
/// InputIterator2 first2, InputIterator2 last2,
|
||||||
/// BinaryPredicate pred )
|
/// BinaryPredicate pred )
|
||||||
@ -29,10 +27,11 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
|||||||
/// \param first2 The start of the second range.
|
/// \param first2 The start of the second range.
|
||||||
/// \param last2 One past the end of the second range.
|
/// \param last2 One past the end of the second range.
|
||||||
/// \param pred A predicate for comparing the elements of the ranges
|
/// \param pred A predicate for comparing the elements of the ranges
|
||||||
|
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||||
std::pair<InputIterator1, InputIterator2> mismatch (
|
std::pair<InputIterator1, InputIterator2> mismatch (
|
||||||
InputIterator1 first1, InputIterator1 last1,
|
InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2,
|
InputIterator2 first2, InputIterator2 last2,
|
||||||
BinaryPredicate pred )
|
BinaryPredicate pred )
|
||||||
{
|
{
|
||||||
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
||||||
if ( !pred ( *first1, *first2 ))
|
if ( !pred ( *first1, *first2 ))
|
||||||
@ -50,8 +49,8 @@ std::pair<InputIterator1, InputIterator2> mismatch (
|
|||||||
/// \param last2 One past the end of the second range.
|
/// \param last2 One past the end of the second range.
|
||||||
template <class InputIterator1, class InputIterator2>
|
template <class InputIterator1, class InputIterator2>
|
||||||
std::pair<InputIterator1, InputIterator2> mismatch (
|
std::pair<InputIterator1, InputIterator2> mismatch (
|
||||||
InputIterator1 first1, InputIterator1 last1,
|
InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2 )
|
InputIterator2 first2, InputIterator2 last2 )
|
||||||
{
|
{
|
||||||
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
||||||
if ( *first1 != *first2 )
|
if ( *first1 != *first2 )
|
||||||
@ -59,7 +58,7 @@ std::pair<InputIterator1, InputIterator2> mismatch (
|
|||||||
return std::pair<InputIterator1, InputIterator2>(first1, first2);
|
return std::pair<InputIterator1, InputIterator2>(first1, first2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are already range-based versions of these.
|
// There are already range-based versions of these.
|
||||||
|
|
||||||
}} // namespace boost and algorithm
|
}} // namespace boost and algorithm
|
||||||
|
|
||||||
|
@ -181,20 +181,20 @@ void find_test()
|
|||||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||||
( (cv_result.end()-str1.begin()) == 6) );
|
( (cv_result.end()-str1.begin()) == 6) );
|
||||||
|
|
||||||
string s1("abc def ghi jkl");
|
string s1("abc def ghi jkl");
|
||||||
find_iterator<string::iterator> fEnd;
|
find_iterator<string::iterator> fEnd;
|
||||||
|
|
||||||
find_iterator<string::iterator> fxIt = make_find_iterator(s1,
|
find_iterator<string::iterator> fxIt = make_find_iterator(s1,
|
||||||
token_finder(is_alnum(), token_compress_on));
|
token_finder(is_alnum(), token_compress_on));
|
||||||
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("abc")));
|
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("abc")));
|
||||||
++fxIt;
|
++fxIt;
|
||||||
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("def")));
|
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("def")));
|
||||||
++fxIt;
|
++fxIt;
|
||||||
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("ghi")));
|
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("ghi")));
|
||||||
++fxIt;
|
++fxIt;
|
||||||
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("jkl")));
|
BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("jkl")));
|
||||||
++fxIt;
|
++fxIt;
|
||||||
BOOST_CHECK(fxIt == fEnd);
|
BOOST_CHECK(fxIt == fEnd);
|
||||||
|
|
||||||
nc_result=find_token( str1, is_any_of("abc"), token_compress_off );
|
nc_result=find_token( str1, is_any_of("abc"), token_compress_off );
|
||||||
BOOST_CHECK(
|
BOOST_CHECK(
|
||||||
|
@ -46,7 +46,7 @@ void iterator_test()
|
|||||||
const char* pch1="xx-abc--xx-abb";
|
const char* pch1="xx-abc--xx-abb";
|
||||||
vector<string> tokens;
|
vector<string> tokens;
|
||||||
vector< vector<int> > vtokens;
|
vector< vector<int> > vtokens;
|
||||||
|
|
||||||
// find_all tests
|
// find_all tests
|
||||||
find_all(
|
find_all(
|
||||||
tokens,
|
tokens,
|
||||||
@ -182,7 +182,7 @@ void iterator_test()
|
|||||||
BOOST_CHECK(siter==split_iterator<string::iterator>());
|
BOOST_CHECK(siter==split_iterator<string::iterator>());
|
||||||
|
|
||||||
// Make sure we work with forward iterators
|
// Make sure we work with forward iterators
|
||||||
// See bug #7989
|
// See bug #7989
|
||||||
list<char> l1;
|
list<char> l1;
|
||||||
find_iterator<list<char>::iterator> liter=make_find_iterator(l1, first_finder("xx"));
|
find_iterator<list<char>::iterator> liter=make_find_iterator(l1, first_finder("xx"));
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) Marshall Clow 2013.
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
For more information, see http://www.boost.org
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef ITERATOR_TEST_H
|
#ifndef ITERATOR_TEST_H
|
||||||
#define ITERATOR_TEST_H
|
#define ITERATOR_TEST_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A set of iterator adapters for constructing test cases
|
A set of iterator adapters for constructing test cases
|
||||||
From an iterator (or a pointer), you can make any class of iterator.
|
From an iterator (or a pointer), you can make any class of iterator.
|
||||||
Assuming you want to degrade the capabilities.
|
Assuming you want to degrade the capabilities.
|
||||||
|
|
||||||
Modeled closely on work that Howard Hinnant did for libc++.
|
Modeled closely on work that Howard Hinnant did for libc++.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -269,10 +278,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
It it_;
|
It it_;
|
||||||
template <typename U> friend class output_iterator;
|
template <typename U> friend class output_iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
// No comparison operators for output iterators
|
// No comparison operators for output iterators
|
||||||
|
|
||||||
|
|
||||||
// == Get the base of an iterator; used for comparisons ==
|
// == Get the base of an iterator; used for comparisons ==
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
@ -290,7 +299,7 @@ inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
|
|||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
|
inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
|
||||||
|
|
||||||
template <typename Iter> // everything else
|
template <typename Iter> // everything else
|
||||||
inline Iter base(Iter i) { return i; }
|
inline Iter base(Iter i) { return i; }
|
||||||
|
|
||||||
#endif // ITERATORS_H
|
#endif // ITERATORS_H
|
||||||
|
Reference in New Issue
Block a user