diff options
Diffstat (limited to 'boost/algorithm')
-rw-r--r-- | boost/algorithm/cxx11/is_partitioned.hpp | 6 | ||||
-rw-r--r-- | boost/algorithm/cxx14/equal.hpp | 3 | ||||
-rw-r--r-- | boost/algorithm/cxx17/exclusive_scan.hpp | 52 | ||||
-rw-r--r-- | boost/algorithm/cxx17/for_each_n.hpp | 37 | ||||
-rw-r--r-- | boost/algorithm/cxx17/inclusive_scan.hpp | 60 | ||||
-rw-r--r-- | boost/algorithm/cxx17/reduce.hpp | 72 | ||||
-rw-r--r-- | boost/algorithm/cxx17/transform_exclusive_scan.hpp | 46 | ||||
-rw-r--r-- | boost/algorithm/cxx17/transform_inclusive_scan.hpp | 58 | ||||
-rw-r--r-- | boost/algorithm/cxx17/transform_reduce.hpp | 55 | ||||
-rw-r--r-- | boost/algorithm/hex.hpp | 2 | ||||
-rw-r--r-- | boost/algorithm/is_palindrome.hpp | 29 | ||||
-rw-r--r-- | boost/algorithm/is_partitioned_until.hpp | 63 | ||||
-rw-r--r-- | boost/algorithm/searching/boyer_moore.hpp | 16 | ||||
-rw-r--r-- | boost/algorithm/searching/knuth_morris_pratt.hpp | 6 | ||||
-rw-r--r-- | boost/algorithm/string/detail/case_conv.hpp | 8 | ||||
-rw-r--r-- | boost/algorithm/string/detail/find_iterator.hpp | 2 | ||||
-rw-r--r-- | boost/algorithm/string/detail/util.hpp | 5 |
17 files changed, 474 insertions, 46 deletions
diff --git a/boost/algorithm/cxx11/is_partitioned.hpp b/boost/algorithm/cxx11/is_partitioned.hpp index cb6c71e33b..c0076b932b 100644 --- a/boost/algorithm/cxx11/is_partitioned.hpp +++ b/boost/algorithm/cxx11/is_partitioned.hpp @@ -18,7 +18,8 @@ namespace boost { namespace algorithm { /// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) -/// \brief Tests to see if a sequence is partitioned according to a predicate +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. /// /// \param first The start of the input sequence /// \param last One past the end of the input sequence @@ -39,7 +40,8 @@ bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p } /// \fn is_partitioned ( const Range &r, UnaryPredicate p ) -/// \brief Generates an increasing sequence of values, and stores them in the input Range. +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. /// /// \param r The input range /// \param p The predicate to test the values with diff --git a/boost/algorithm/cxx14/equal.hpp b/boost/algorithm/cxx14/equal.hpp index f1539f885c..9f97be1d62 100644 --- a/boost/algorithm/cxx14/equal.hpp +++ b/boost/algorithm/cxx14/equal.hpp @@ -13,7 +13,6 @@ #define BOOST_ALGORITHM_EQUAL_HPP #include <algorithm> // for std::equal -#include <functional> // for std::binary_function #include <iterator> namespace boost { namespace algorithm { @@ -21,7 +20,7 @@ namespace boost { namespace algorithm { namespace detail { template <class T1, class T2> - struct eq : public std::binary_function<T1, T2, bool> { + struct eq { bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;} }; diff --git a/boost/algorithm/cxx17/exclusive_scan.hpp b/boost/algorithm/cxx17/exclusive_scan.hpp new file mode 100644 index 0000000000..03ecea52ec --- /dev/null +++ b/boost/algorithm/cxx17/exclusive_scan.hpp @@ -0,0 +1,52 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file exclusive_scan.hpp +/// \brief ??? +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP +#define BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, class T, class BinaryOperation> +OutputIterator exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, BinaryOperation bOp) +{ + if (first != last) + { + T saved = init; + do + { + init = bOp(init, *first); + *result = saved; + saved = init; + ++result; + } while (++first != last); + } + return result; +} + +template<class InputIterator, class OutputIterator, class T> +OutputIterator exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return exclusive_scan(first, last, result, init, std::plus<VT>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP diff --git a/boost/algorithm/cxx17/for_each_n.hpp b/boost/algorithm/cxx17/for_each_n.hpp new file mode 100644 index 0000000000..b8134cc06a --- /dev/null +++ b/boost/algorithm/cxx17/for_each_n.hpp @@ -0,0 +1,37 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file for_each_n.hpp +/// \brief Apply a functor to the elements of a sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP +#define BOOST_ALGORITHM_FOR_EACH_N_HPP + +#include <utility> // for std::pair + +namespace boost { namespace algorithm { + +/// \fn for_each_n(InputIterator first, Size n, Function f); +/// \return first + n +/// +/// \param first The start of the first range. +/// \param n One past the end of the first range. +/// \param f A functor to apply to the elements of the sequence +/// \note If f returns a result, the result is ignored. +template<class InputIterator, class Size, class Function> +InputIterator for_each_n(InputIterator first, Size n, Function f) +{ + for ( ; n > 0; --n, ++first ) + f(*first); + + return first; +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_FOR_EACH_N_HPP diff --git a/boost/algorithm/cxx17/inclusive_scan.hpp b/boost/algorithm/cxx17/inclusive_scan.hpp new file mode 100644 index 0000000000..cd015f100f --- /dev/null +++ b/boost/algorithm/cxx17/inclusive_scan.hpp @@ -0,0 +1,60 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP +#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, class T, class BinaryOperation> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation bOp, T init) +{ + for (; first != last; ++first, (void) ++result) { + init = bOp(init, *first); + *result = init; + } + return result; +} + + +template<class InputIterator, class OutputIterator, class BinaryOperation> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation bOp) +{ + if (first != last) { + typename std::iterator_traits<InputIterator>::value_type init = *first; + *result++ = init; + if (++first != last) + return inclusive_scan(first, last, result, bOp, init); + } + + return result; +} + +template<class InputIterator, class OutputIterator> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return inclusive_scan(first, last, result, std::plus<VT>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/reduce.hpp b/boost/algorithm/cxx17/reduce.hpp new file mode 100644 index 0000000000..f47695b53a --- /dev/null +++ b/boost/algorithm/cxx17/reduce.hpp @@ -0,0 +1,72 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file reduce.hpp +/// \brief Combine the elements of a sequence into a single value +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_REDUCE_HPP +#define BOOST_ALGORITHM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class T, class BinaryOperation> +T reduce(InputIterator first, InputIterator last, T init, BinaryOperation bOp) +{ + ; + for (; first != last; ++first) + init = bOp(init, *first); + return init; +} + +template<class InputIterator, class T> +T reduce(InputIterator first, InputIterator last, T init) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return reduce(first, last, init, std::plus<VT>()); +} + +template<class InputIterator> +typename std::iterator_traits<InputIterator>::value_type +reduce(InputIterator first, InputIterator last) +{ + return reduce(first, last, + typename std::iterator_traits<InputIterator>::value_type()); +} + +template<class Range> +typename boost::range_value<Range>::type +reduce(const Range &r) +{ + return reduce(boost::begin(r), boost::end(r)); +} + +// Not sure that this won't be ambiguous (1) +template<class Range, class T> +T reduce(const Range &r, T init) +{ + return reduce(boost::begin (r), boost::end (r), init); +} + + +// Not sure that this won't be ambiguous (2) +template<class Range, class T, class BinaryOperation> +T reduce(const Range &r, T init, BinaryOperation bOp) +{ + return reduce(boost::begin(r), boost::end(r), init, bOp); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/transform_exclusive_scan.hpp b/boost/algorithm/cxx17/transform_exclusive_scan.hpp new file mode 100644 index 0000000000..d3b4329a0a --- /dev/null +++ b/boost/algorithm/cxx17/transform_exclusive_scan.hpp @@ -0,0 +1,46 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file transform_exclusive_scan.hpp +/// \brief ???? +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, class T, + class BinaryOperation, class UnaryOperation> +OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, + BinaryOperation bOp, UnaryOperation uOp) +{ + if (first != last) + { + T saved = init; + do + { + init = bOp(init, uOp(*first)); + *result = saved; + saved = init; + ++result; + } while (++first != last); + } + return result; +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/boost/algorithm/cxx17/transform_inclusive_scan.hpp b/boost/algorithm/cxx17/transform_inclusive_scan.hpp new file mode 100644 index 0000000000..476c117f92 --- /dev/null +++ b/boost/algorithm/cxx17/transform_inclusive_scan.hpp @@ -0,0 +1,58 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP +#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, + class BinaryOperation, class UnaryOperation, class T> +OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation bOp, UnaryOperation uOp, + T init) +{ + for (; first != last; ++first, (void) ++result) { + init = bOp(init, uOp(*first)); + *result = init; + } + + return result; +} + +template<class InputIterator, class OutputIterator, + class BinaryOperation, class UnaryOperation> +OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation bOp, UnaryOperation uOp) +{ + if (first != last) { + typename std::iterator_traits<InputIterator>::value_type init = uOp(*first); + *result++ = init; + if (++first != last) + return transform_inclusive_scan(first, last, result, bOp, uOp, init); + } + + return result; +} + + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/transform_reduce.hpp b/boost/algorithm/cxx17/transform_reduce.hpp new file mode 100644 index 0000000000..7ebde7d325 --- /dev/null +++ b/boost/algorithm/cxx17/transform_reduce.hpp @@ -0,0 +1,55 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP +#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator1, class InputIterator2, class T, + class BinaryOperation1, class BinaryOperation2> +T transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 bOp1, BinaryOperation2 bOp2) +{ + for (; first1 != last1; ++first1, (void) ++first2) + init = bOp1(init, bOp2(*first1, *first2)); + return init; +} + +template<class InputIterator, class T, + class BinaryOperation, class UnaryOperation> +T transform_reduce(InputIterator first, InputIterator last, + T init, BinaryOperation bOp, UnaryOperation uOp) +{ + for (; first != last; ++first) + init = bOp(init, uOp(*first)); + return init; +} + +template<class InputIterator1, class InputIterator2, class T> +T transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) +{ + return transform_reduce(first1, last1, first2, init, + std::plus<T>(), std::multiplies<T>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/hex.hpp b/boost/algorithm/hex.hpp index 739e89f2f0..b8335843a8 100644 --- a/boost/algorithm/hex.hpp +++ b/boost/algorithm/hex.hpp @@ -73,7 +73,7 @@ namespace detail { else if ( c >= 'A' && c <= 'F' ) retval = c - 'A' + 10; else if ( c >= 'a' && c <= 'f' ) retval = c - 'a' + 10; else BOOST_THROW_EXCEPTION (non_hex_input() << bad_char (c)); - return retval; + return static_cast<char>(retval); } // My own iterator_traits class. diff --git a/boost/algorithm/is_palindrome.hpp b/boost/algorithm/is_palindrome.hpp index cc63e18075..09881109a3 100644 --- a/boost/algorithm/is_palindrome.hpp +++ b/boost/algorithm/is_palindrome.hpp @@ -35,7 +35,7 @@ namespace boost { namespace algorithm { /// For other sequences function will return false. /// Complexity: O(N). template <typename BidirectionalIterator, typename Predicate> -bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predicate p ) +bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predicate p) { if(begin == end) { @@ -63,7 +63,7 @@ bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predi /// \return true if the entire sequence is palindrome /// /// \param begin The start of the input sequence -/// \param end One past the end of the input sequence +/// \param end One past the end of the input sequence /// /// \note This function will return true for empty sequences and for palindromes. /// For other sequences function will return false. @@ -71,26 +71,8 @@ bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predi template <typename BidirectionalIterator> bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end) { - if(begin == end) - { - return true; - } - - --end; - while(begin != end) - { - if(!(*begin == *end)) - { - return false; - } - ++begin; - if(begin == end) - { - break; - } - --end; - } - return true; + return is_palindrome(begin, end, + std::equal_to<typename std::iterator_traits<BidirectionalIterator>::value_type> ()); } /// \fn is_palindrome ( const R& range ) @@ -122,7 +104,6 @@ bool is_palindrome(const R& range, Predicate p) return is_palindrome(boost::begin(range), boost::end(range), p); } - /// \fn is_palindrome ( const char* str ) /// \return true if the entire sequence is palindrome /// @@ -138,7 +119,6 @@ bool is_palindrome(const char* str) return is_palindrome(str, str + strlen(str)); } - /// \fn is_palindrome ( const char* str, Predicate p ) /// \return true if the entire sequence is palindrome /// @@ -155,7 +135,6 @@ bool is_palindrome(const char* str, Predicate p) return true; return is_palindrome(str, str + strlen(str), p); } - }} #endif // BOOST_ALGORITHM_IS_PALINDROME_HPP diff --git a/boost/algorithm/is_partitioned_until.hpp b/boost/algorithm/is_partitioned_until.hpp new file mode 100644 index 0000000000..42683e1d8e --- /dev/null +++ b/boost/algorithm/is_partitioned_until.hpp @@ -0,0 +1,63 @@ +/* + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.by>, 2017. + + 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) +*/ + +/// \file is_partitioned_until.hpp +/// \brief Tell if a sequence is partitioned +/// \author Alexander Zaitsev + +#ifndef BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP +#define BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p The predicate to test the values with +/// +/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. +/// Returns last if the entire sequence is partitioned. +/// Complexity: O(N). +template <typename InputIterator, typename UnaryPredicate> +InputIterator is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) +{ +// Run through the part that satisfy the predicate + for ( ; first != last; ++first ) + if ( !p (*first)) + break; +// Now the part that does not satisfy the predicate + for ( ; first != last; ++first ) + if ( p (*first)) + return first; + return last; +} + +/// \fn is_partitioned_until ( const Range &r, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param r The input range +/// \param p The predicate to test the values with +/// +/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. +/// Returns last if the entire sequence is partitioned. +/// Complexity: O(N). +template <typename Range, typename UnaryPredicate> +typename boost::range_iterator<const Range>::type is_partitioned_until ( const Range &r, UnaryPredicate p ) +{ + return boost::algorithm::is_partitioned_until (boost::begin(r), boost::end(r), p); +} + +}} + +#endif // BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP diff --git a/boost/algorithm/searching/boyer_moore.hpp b/boost/algorithm/searching/boyer_moore.hpp index 65a809dd4f..192d4dec25 100644 --- a/boost/algorithm/searching/boyer_moore.hpp +++ b/boost/algorithm/searching/boyer_moore.hpp @@ -152,8 +152,8 @@ Requirements: template<typename Iter, typename Container> - void compute_bm_prefix ( Iter pat_first, Iter pat_last, Container &prefix ) { - const std::size_t count = std::distance ( pat_first, pat_last ); + void compute_bm_prefix ( Iter first, Iter last, Container &prefix ) { + const std::size_t count = std::distance ( first, last ); BOOST_ASSERT ( count > 0 ); BOOST_ASSERT ( prefix.size () == count ); @@ -161,26 +161,26 @@ Requirements: std::size_t k = 0; for ( std::size_t i = 1; i < count; ++i ) { BOOST_ASSERT ( k < count ); - while ( k > 0 && ( pat_first[k] != pat_first[i] )) { + while ( k > 0 && ( first[k] != first[i] )) { BOOST_ASSERT ( k < count ); k = prefix [ k - 1 ]; } - if ( pat_first[k] == pat_first[i] ) + if ( first[k] == first[i] ) k++; prefix [ i ] = k; } } - void build_suffix_table ( patIter pat_first, patIter pat_last ) { - const std::size_t count = (std::size_t) std::distance ( pat_first, pat_last ); + void build_suffix_table ( patIter first, patIter last ) { + const std::size_t count = (std::size_t) std::distance ( first, last ); if ( count > 0 ) { // empty pattern std::vector<typename std::iterator_traits<patIter>::value_type> reversed(count); - (void) std::reverse_copy ( pat_first, pat_last, reversed.begin ()); + (void) std::reverse_copy ( first, last, reversed.begin ()); std::vector<difference_type> prefix (count); - compute_bm_prefix ( pat_first, pat_last, prefix ); + compute_bm_prefix ( first, last, prefix ); std::vector<difference_type> prefix_reversed (count); compute_bm_prefix ( reversed.begin (), reversed.end (), prefix_reversed ); diff --git a/boost/algorithm/searching/knuth_morris_pratt.hpp b/boost/algorithm/searching/knuth_morris_pratt.hpp index c890c9cac0..5b5b64a729 100644 --- a/boost/algorithm/searching/knuth_morris_pratt.hpp +++ b/boost/algorithm/searching/knuth_morris_pratt.hpp @@ -155,9 +155,9 @@ namespace boost { namespace algorithm { void preKmp ( patIter first, patIter last ) { - const /*std::size_t*/ int count = std::distance ( first, last ); + const difference_type count = std::distance ( first, last ); - int i, j; + difference_type i, j; i = 0; j = skip_[0] = -1; @@ -177,7 +177,7 @@ namespace boost { namespace algorithm { void init_skip_table ( patIter first, patIter last ) { const difference_type count = std::distance ( first, last ); - int j; + difference_type j; skip_ [ 0 ] = -1; for ( int i = 1; i <= count; ++i ) { j = skip_ [ i - 1 ]; diff --git a/boost/algorithm/string/detail/case_conv.hpp b/boost/algorithm/string/detail/case_conv.hpp index 42621c74f0..233912ca0f 100644 --- a/boost/algorithm/string/detail/case_conv.hpp +++ b/boost/algorithm/string/detail/case_conv.hpp @@ -30,8 +30,10 @@ namespace boost { // a tolower functor template<typename CharT> - struct to_lowerF : public std::unary_function<CharT, CharT> + struct to_lowerF { + typedef CharT argument_type; + typedef CharT result_type; // Constructor to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {} @@ -50,8 +52,10 @@ namespace boost { // a toupper functor template<typename CharT> - struct to_upperF : public std::unary_function<CharT, CharT> + struct to_upperF { + typedef CharT argument_type; + typedef CharT result_type; // Constructor to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {} diff --git a/boost/algorithm/string/detail/find_iterator.hpp b/boost/algorithm/string/detail/find_iterator.hpp index 9b78a0f7e1..4f90a98fc0 100644 --- a/boost/algorithm/string/detail/find_iterator.hpp +++ b/boost/algorithm/string/detail/find_iterator.hpp @@ -40,7 +40,7 @@ namespace boost { // Protected construction/destruction // Default constructor - find_iterator_base() {}; + find_iterator_base() {} // Copy construction find_iterator_base( const find_iterator_base& Other ) : m_Finder(Other.m_Finder) {} diff --git a/boost/algorithm/string/detail/util.hpp b/boost/algorithm/string/detail/util.hpp index cf4a8b1c8c..7844b6723c 100644 --- a/boost/algorithm/string/detail/util.hpp +++ b/boost/algorithm/string/detail/util.hpp @@ -89,9 +89,10 @@ namespace boost { template< typename SeqT, typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator > - struct copy_iterator_rangeF : - public std::unary_function< iterator_range<IteratorT>, SeqT > + struct copy_iterator_rangeF { + typedef iterator_range<IteratorT> argument_type; + typedef SeqT result_type; SeqT operator()( const iterator_range<IteratorT>& Range ) const { return copy_range<SeqT>(Range); |