diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/algorithm/cxx11/copy_if.hpp | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/algorithm/cxx11/copy_if.hpp')
-rw-r--r-- | boost/algorithm/cxx11/copy_if.hpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/boost/algorithm/cxx11/copy_if.hpp b/boost/algorithm/cxx11/copy_if.hpp index 6d0ba00bae..88b79b500b 100644 --- a/boost/algorithm/cxx11/copy_if.hpp +++ b/boost/algorithm/cxx11/copy_if.hpp @@ -39,7 +39,7 @@ OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator { for ( ; first != last; ++first ) if (p(*first)) - *result++ = first; + *result++ = *first; return result; } #endif @@ -63,7 +63,7 @@ OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p ) /// \fn copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) /// \brief Copies all the elements at the start of the input range that /// satisfy the predicate to the output range. -/// \return The updated output iterator +/// \return The updated input and output iterators /// /// \param first The start of the input sequence /// \param last One past the end of the input sequence @@ -71,25 +71,26 @@ OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p ) /// \param p A predicate for testing the elements of the range /// template<typename InputIterator, typename OutputIterator, typename Predicate> -OutputIterator copy_while ( InputIterator first, InputIterator last, - OutputIterator result, Predicate p ) +std::pair<InputIterator, OutputIterator> +copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) { for ( ; first != last && p(*first); ++first ) - *result++ = first; - return result; + *result++ = *first; + return std::make_pair(first, result); } /// \fn copy_while ( const Range &r, OutputIterator result, Predicate p ) /// \brief Copies all the elements at the start of the input range that /// satisfy the predicate to the output range. -/// \return The updated output iterator +/// \return The updated input and output iterators /// /// \param r The input range /// \param result An output iterator to write the results into /// \param p A predicate for testing the elements of the range /// template<typename Range, typename OutputIterator, typename Predicate> -OutputIterator copy_while ( const Range &r, OutputIterator result, Predicate p ) +std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_while ( const Range &r, OutputIterator result, Predicate p ) { return boost::algorithm::copy_while (boost::begin (r), boost::end(r), result, p); } @@ -106,11 +107,12 @@ OutputIterator copy_while ( const Range &r, OutputIterator result, Predicate p ) /// \param p A predicate for testing the elements of the range /// template<typename InputIterator, typename OutputIterator, typename Predicate> -OutputIterator copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +std::pair<InputIterator, OutputIterator> +copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) { for ( ; first != last && !p(*first); ++first ) - *result++ = first; - return result; + *result++ = *first; + return std::make_pair(first, result); } /// \fn copy_until ( const Range &r, OutputIterator result, Predicate p ) @@ -123,7 +125,8 @@ OutputIterator copy_until ( InputIterator first, InputIterator last, OutputItera /// \param p A predicate for testing the elements of the range /// template<typename Range, typename OutputIterator, typename Predicate> -OutputIterator copy_until ( const Range &r, OutputIterator result, Predicate p ) +std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_until ( const Range &r, OutputIterator result, Predicate p ) { return boost::algorithm::copy_until (boost::begin (r), boost::end(r), result, p); } |