File indexing completed on 2025-01-18 09:29:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/algorithm/transform_if.hpp>
0017 #include <boost/compute/functional/identity.hpp>
0018 #include <boost/compute/type_traits/is_device_iterator.hpp>
0019
0020 namespace boost {
0021 namespace compute {
0022 namespace detail {
0023
0024
0025
0026 template<class InputIterator, class OutputIterator, class Predicate>
0027 inline OutputIterator copy_index_if(InputIterator first,
0028 InputIterator last,
0029 OutputIterator result,
0030 Predicate predicate,
0031 command_queue &queue = system::default_queue())
0032 {
0033 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0034 BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
0035 typedef typename std::iterator_traits<InputIterator>::value_type T;
0036
0037 return detail::transform_if_impl(
0038 first, last, result, identity<T>(), predicate, true, queue
0039 );
0040 }
0041
0042 }
0043
0044
0045
0046
0047
0048 template<class InputIterator, class OutputIterator, class Predicate>
0049 inline OutputIterator copy_if(InputIterator first,
0050 InputIterator last,
0051 OutputIterator result,
0052 Predicate predicate,
0053 command_queue &queue = system::default_queue())
0054 {
0055 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0056 BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
0057 typedef typename std::iterator_traits<InputIterator>::value_type T;
0058
0059 return ::boost::compute::transform_if(
0060 first, last, result, identity<T>(), predicate, queue
0061 );
0062 }
0063
0064 }
0065 }
0066
0067 #endif