123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
- #define BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
- #include <boost/static_assert.hpp>
- #include <boost/compute/system.hpp>
- #include <boost/compute/functional.hpp>
- #include <boost/compute/command_queue.hpp>
- #include <boost/compute/algorithm/copy_if.hpp>
- #include <boost/compute/type_traits/is_device_iterator.hpp>
- namespace boost {
- namespace compute {
- template<class InputIterator,
- class OutputIterator1,
- class OutputIterator2,
- class UnaryPredicate>
- inline std::pair<OutputIterator1, OutputIterator2>
- partition_copy(InputIterator first,
- InputIterator last,
- OutputIterator1 first_true,
- OutputIterator2 first_false,
- UnaryPredicate predicate,
- command_queue &queue = system::default_queue())
- {
- BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
- BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator1>::value);
- BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator2>::value);
-
- OutputIterator1 last_true =
- ::boost::compute::copy_if(first,
- last,
- first_true,
- predicate,
- queue);
-
- OutputIterator2 last_false =
- ::boost::compute::copy_if(first,
- last,
- first_false,
- not1(predicate),
- queue);
-
- return std::make_pair(last_true, last_false);
- }
- }
- }
- #endif
|