]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/algorithm/copy_if.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / algorithm / copy_if.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_COPY_IF_HPP
12 #define BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP
13
14 #include <boost/compute/algorithm/transform_if.hpp>
15 #include <boost/compute/functional/identity.hpp>
16
17 namespace boost {
18 namespace compute {
19 namespace detail {
20
21 // like the copy_if() algorithm but writes the indices of the values for which
22 // predicate returns true.
23 template<class InputIterator, class OutputIterator, class Predicate>
24 inline OutputIterator copy_index_if(InputIterator first,
25 InputIterator last,
26 OutputIterator result,
27 Predicate predicate,
28 command_queue &queue = system::default_queue())
29 {
30 typedef typename std::iterator_traits<InputIterator>::value_type T;
31
32 return detail::transform_if_impl(
33 first, last, result, identity<T>(), predicate, true, queue
34 );
35 }
36
37 } // end detail namespace
38
39 /// Copies each element in the range [\p first, \p last) for which
40 /// \p predicate returns \c true to the range beginning at \p result.
41 ///
42 /// Space complexity: \Omega(2n)
43 template<class InputIterator, class OutputIterator, class Predicate>
44 inline OutputIterator copy_if(InputIterator first,
45 InputIterator last,
46 OutputIterator result,
47 Predicate predicate,
48 command_queue &queue = system::default_queue())
49 {
50 typedef typename std::iterator_traits<InputIterator>::value_type T;
51
52 return ::boost::compute::transform_if(
53 first, last, result, identity<T>(), predicate, queue
54 );
55 }
56
57 } // end compute namespace
58 } // end boost namespace
59
60 #endif // BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP