File indexing completed on 2025-01-18 09:29:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/functional.hpp>
0018 #include <boost/compute/command_queue.hpp>
0019 #include <boost/compute/algorithm/copy_if.hpp>
0020 #include <boost/compute/type_traits/is_device_iterator.hpp>
0021
0022 namespace boost {
0023 namespace compute {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 template<class InputIterator,
0034 class OutputIterator1,
0035 class OutputIterator2,
0036 class UnaryPredicate>
0037 inline std::pair<OutputIterator1, OutputIterator2>
0038 partition_copy(InputIterator first,
0039 InputIterator last,
0040 OutputIterator1 first_true,
0041 OutputIterator2 first_false,
0042 UnaryPredicate predicate,
0043 command_queue &queue = system::default_queue())
0044 {
0045 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0046 BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator1>::value);
0047 BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator2>::value);
0048
0049
0050 OutputIterator1 last_true =
0051 ::boost::compute::copy_if(first,
0052 last,
0053 first_true,
0054 predicate,
0055 queue);
0056
0057
0058 OutputIterator2 last_false =
0059 ::boost::compute::copy_if(first,
0060 last,
0061 first_false,
0062 not1(predicate),
0063 queue);
0064
0065
0066 return std::make_pair(last_true, last_false);
0067 }
0068
0069 }
0070 }
0071
0072 #endif