]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/algorithm/count.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / count.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_COUNT_HPP
12#define BOOST_COMPUTE_ALGORITHM_COUNT_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/count_if.hpp>
18#include <boost/compute/type_traits/vector_size.hpp>
19
20namespace boost {
21namespace compute {
22
23/// Returns the number of occurrences of \p value in the range
24/// [\p first, \p last).
25///
26/// \see count_if()
27template<class InputIterator, class T>
28inline size_t count(InputIterator first,
29 InputIterator last,
30 const T &value,
31 command_queue &queue = system::default_queue())
32{
33 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
34
35 using ::boost::compute::_1;
36 using ::boost::compute::lambda::all;
37
38 if(vector_size<value_type>::value == 1){
39 return ::boost::compute::count_if(first,
40 last,
41 _1 == value,
42 queue);
43 }
44 else {
45 return ::boost::compute::count_if(first,
46 last,
47 all(_1 == value),
48 queue);
49 }
50}
51
52} // end compute namespace
53} // end boost namespace
54
55#endif // BOOST_COMPUTE_ALGORITHM_COUNT_HPP