]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/algorithm/find.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / find.hpp
CommitLineData
7c673cae
FG
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_FIND_HPP
12#define BOOST_COMPUTE_ALGORITHM_FIND_HPP
13
14#include <boost/compute/lambda.hpp>
15#include <boost/compute/system.hpp>
16#include <boost/compute/command_queue.hpp>
17#include <boost/compute/algorithm/find_if.hpp>
18#include <boost/compute/type_traits/vector_size.hpp>
19
20namespace boost {
21namespace compute {
22
23/// Returns an iterator pointing to the first element in the range
24/// [\p first, \p last) that equals \p value.
25template<class InputIterator, class T>
26inline InputIterator find(InputIterator first,
27 InputIterator last,
28 const T &value,
29 command_queue &queue = system::default_queue())
30{
31 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
32
33 using ::boost::compute::_1;
34 using ::boost::compute::lambda::all;
35
36 if(vector_size<value_type>::value == 1){
37 return ::boost::compute::find_if(
38 first,
39 last,
40 _1 == value,
41 queue
42 );
43 }
44 else {
45 return ::boost::compute::find_if(
46 first,
47 last,
48 all(_1 == value),
49 queue
50 );
51 }
52}
53
54} // end compute namespace
55} // end boost namespace
56
57#endif // BOOST_COMPUTE_ALGORITHM_FIND_HPP