]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/algorithm/swap_ranges.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / swap_ranges.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
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
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #ifndef BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
12 #define BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/copy.hpp>
17 #include <boost/compute/container/vector.hpp>
18
19 namespace boost {
20 namespace compute {
21
22 /// Swaps the elements in the range [\p first1, \p last1) with the
23 /// elements in the range beginning at \p first2.
24 template<class Iterator1, class Iterator2>
25 inline Iterator2 swap_ranges(Iterator1 first1,
26 Iterator1 last1,
27 Iterator2 first2,
28 command_queue &queue = system::default_queue())
29 {
30 typedef typename std::iterator_traits<Iterator1>::value_type value_type;
31
32 Iterator2 last2 = first2 + std::distance(first1, last1);
33
34 ::boost::compute::vector<value_type> tmp(first1, last1, queue);
35 ::boost::compute::copy(first2, last2, first1, queue);
36 ::boost::compute::copy(tmp.begin(), tmp.end(), first2, queue);
37
38 return last2;
39 }
40
41 } // end compute namespace
42 } // end boost namespace
43
44 #endif // BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP