1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ALGORITHM_REPLACE_COPY_HPP
12 #define BOOST_COMPUTE_ALGORITHM_REPLACE_COPY_HPP
16 #include <boost/compute/system.hpp>
17 #include <boost/compute/command_queue.hpp>
18 #include <boost/compute/algorithm/copy.hpp>
19 #include <boost/compute/algorithm/replace.hpp>
24 /// Copies the value in the range [\p first, \p last) to the range
25 /// beginning at \p result while replacing each instance of \p old_value
26 /// with \p new_value.
29 template<class InputIterator, class OutputIterator, class T>
31 replace_copy(InputIterator first,
33 OutputIterator result,
36 command_queue &queue = system::default_queue())
38 typedef typename std::iterator_traits<OutputIterator>::difference_type difference_type;
40 difference_type count = std::distance(first, last);
45 // copy data to result
46 ::boost::compute::copy(first, last, result, queue);
49 ::boost::compute::replace(result,
55 // return iterator to the end of result
56 return result + count;
59 } // end compute namespace
60 } // end boost namespace
62 #endif // BOOST_COMPUTE_ALGORITHM_REPLACE_COPY_HPP