1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
12 #define BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/functional.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/copy_if.hpp>
22 /// Copies all of the elements in the range [\p first, \p last) for which
23 /// \p predicate returns \c true to the range beginning at \p first_true
24 /// and all of the elements for which \p predicate returns \c false to
25 /// the range beginning at \p first_false.
28 template<class InputIterator,
29 class OutputIterator1,
30 class OutputIterator2,
32 inline std::pair<OutputIterator1, OutputIterator2>
33 partition_copy(InputIterator first,
35 OutputIterator1 first_true,
36 OutputIterator2 first_false,
37 UnaryPredicate predicate,
38 command_queue &queue = system::default_queue())
41 OutputIterator1 last_true =
42 ::boost::compute::copy_if(first,
49 OutputIterator2 last_false =
50 ::boost::compute::copy_if(first,
56 // return iterators to the end of the true and the false ranges
57 return std::make_pair(last_true, last_false);
60 } // end compute namespace
61 } // end boost namespace
63 #endif // BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP