annotate DEPENDENCIES/generic/include/boost/algorithm/cxx11/partition_copy.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright (c) Marshall Clow 2011-2012.
Chris@16 3
Chris@16 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7
Chris@16 8 /// \file partition_copy.hpp
Chris@16 9 /// \brief Copy a subset of a sequence to a new sequence
Chris@16 10 /// \author Marshall Clow
Chris@16 11
Chris@16 12 #ifndef BOOST_ALGORITHM_PARTITION_COPY_HPP
Chris@16 13 #define BOOST_ALGORITHM_PARTITION_COPY_HPP
Chris@16 14
Chris@16 15 #include <algorithm> // for std::partition_copy, if available
Chris@16 16 #include <utility> // for make_pair
Chris@16 17
Chris@16 18 #include <boost/range/begin.hpp>
Chris@16 19 #include <boost/range/end.hpp>
Chris@16 20
Chris@16 21 namespace boost { namespace algorithm {
Chris@16 22
Chris@16 23 /// \fn partition_copy ( InputIterator first, InputIterator last,
Chris@16 24 /// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p )
Chris@16 25 /// \brief Copies the elements that satisfy the predicate p from the range [first, last)
Chris@16 26 /// to the range beginning at d_first_true, and
Chris@16 27 /// copies the elements that do not satisfy p to the range beginning at d_first_false.
Chris@16 28 ///
Chris@16 29 ///
Chris@16 30 /// \param first The start of the input sequence
Chris@16 31 /// \param last One past the end of the input sequence
Chris@16 32 /// \param out_true An output iterator to write the elements that satisfy the predicate into
Chris@16 33 /// \param out_false An output iterator to write the elements that do not satisfy the predicate into
Chris@16 34 /// \param p A predicate for dividing the elements of the input sequence.
Chris@16 35 ///
Chris@16 36 /// \note This function is part of the C++2011 standard library.
Chris@16 37 /// We will use the standard one if it is available,
Chris@16 38 /// otherwise we have our own implementation.
Chris@16 39 template <typename InputIterator,
Chris@16 40 typename OutputIterator1, typename OutputIterator2, typename UnaryPredicate>
Chris@16 41 std::pair<OutputIterator1, OutputIterator2>
Chris@16 42 partition_copy ( InputIterator first, InputIterator last,
Chris@16 43 OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p )
Chris@16 44 {
Chris@16 45 for ( ; first != last; ++first )
Chris@16 46 if ( p (*first))
Chris@16 47 *out_true++ = *first;
Chris@16 48 else
Chris@16 49 *out_false++ = *first;
Chris@16 50 return std::pair<OutputIterator1, OutputIterator2> ( out_true, out_false );
Chris@16 51 }
Chris@16 52
Chris@16 53 /// \fn partition_copy ( const Range &r,
Chris@16 54 /// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p )
Chris@16 55 ///
Chris@16 56 /// \param r The input range
Chris@16 57 /// \param out_true An output iterator to write the elements that satisfy the predicate into
Chris@16 58 /// \param out_false An output iterator to write the elements that do not satisfy the predicate into
Chris@16 59 /// \param p A predicate for dividing the elements of the input sequence.
Chris@16 60 ///
Chris@16 61 template <typename Range, typename OutputIterator1, typename OutputIterator2,
Chris@16 62 typename UnaryPredicate>
Chris@16 63 std::pair<OutputIterator1, OutputIterator2>
Chris@16 64 partition_copy ( const Range &r, OutputIterator1 out_true, OutputIterator2 out_false,
Chris@16 65 UnaryPredicate p )
Chris@16 66 {
Chris@16 67 return boost::algorithm::partition_copy
Chris@16 68 (boost::begin(r), boost::end(r), out_true, out_false, p );
Chris@16 69 }
Chris@16 70
Chris@16 71 }} // namespace boost and algorithm
Chris@16 72
Chris@16 73 #endif // BOOST_ALGORITHM_PARTITION_COPY_HPP