]>
Commit | Line | Data |
---|---|---|
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_EXPERIMENTAL_CLAMP_RANGE_HPP | |
12 | #define BOOST_COMPUTE_EXPERIMENTAL_CLAMP_RANGE_HPP | |
13 | ||
14 | #include <iterator> | |
15 | ||
16 | #include <boost/compute/lambda.hpp> | |
17 | #include <boost/compute/algorithm/transform.hpp> | |
18 | ||
19 | namespace boost { | |
20 | namespace compute { | |
21 | namespace experimental { | |
22 | ||
23 | template<class InputIterator, class OutputIterator> | |
24 | inline OutputIterator | |
25 | clamp_range(InputIterator first, | |
26 | InputIterator last, | |
27 | OutputIterator result, | |
28 | typename std::iterator_traits<InputIterator>::value_type lo, | |
29 | typename std::iterator_traits<InputIterator>::value_type hi, | |
30 | command_queue &queue) | |
31 | { | |
32 | using ::boost::compute::lambda::_1; | |
33 | using ::boost::compute::lambda::_2; | |
34 | using ::boost::compute::lambda::clamp; | |
35 | ||
36 | return ::boost::compute::transform( | |
37 | first, | |
38 | last, | |
39 | result, | |
40 | clamp(_1, lo, hi), | |
41 | queue | |
42 | ); | |
43 | } | |
44 | ||
45 | } // end experimental namespace | |
46 | } // end compute namespace | |
47 | } // end boost namespace | |
48 | ||
49 | #endif // BOOST_COMPUTE_EXPERIMENTAL_CLAMP_RANGE_HPP |