File indexing completed on 2025-01-18 09:29:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/command_queue.hpp>
0018 #include <boost/compute/algorithm/copy.hpp>
0019 #include <boost/compute/container/vector.hpp>
0020 #include <boost/compute/type_traits/is_device_iterator.hpp>
0021
0022 namespace boost {
0023 namespace compute {
0024
0025
0026
0027
0028
0029 template<class Iterator1, class Iterator2>
0030 inline Iterator2 swap_ranges(Iterator1 first1,
0031 Iterator1 last1,
0032 Iterator2 first2,
0033 command_queue &queue = system::default_queue())
0034 {
0035 BOOST_STATIC_ASSERT(is_device_iterator<Iterator1>::value);
0036 BOOST_STATIC_ASSERT(is_device_iterator<Iterator2>::value);
0037
0038 typedef typename std::iterator_traits<Iterator1>::value_type value_type;
0039
0040 Iterator2 last2 = first2 + std::distance(first1, last1);
0041
0042 ::boost::compute::vector<value_type> tmp(first1, last1, queue);
0043 ::boost::compute::copy(first2, last2, first1, queue);
0044 ::boost::compute::copy(tmp.begin(), tmp.end(), first2, queue);
0045
0046 return last2;
0047 }
0048
0049 }
0050 }
0051
0052 #endif