]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/functional/identity.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / functional / identity.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013-2014 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_FUNCTIONAL_IDENTITY_HPP
12#define BOOST_COMPUTE_FUNCTIONAL_IDENTITY_HPP
13
14namespace boost {
15namespace compute {
16namespace detail {
17
18template<class T, class Arg>
19struct invoked_identity
20{
21 typedef T result_type;
22
23 invoked_identity(const Arg &arg)
24 : m_arg(arg)
25 {
26 }
27
28 Arg m_arg;
29};
30
31} // end detail namespace
32
33/// Identity function which simply returns its input.
34///
35/// For example, to directly copy values using the transform() algorithm:
36/// \code
37/// transform(input.begin(), input.end(), output.begin(), identity<int>(), queue);
38/// \endcode
39///
40/// \see \ref as "as<T>", \ref convert "convert<T>"
41template<class T>
42class identity
43{
44public:
45 /// Identity function result type.
46 typedef T result_type;
47
48 /// Creates a new identity function.
49 identity()
50 {
51 }
52
53 /// \internal_
54 template<class Arg>
55 detail::invoked_identity<T, Arg> operator()(const Arg &arg) const
56 {
57 return detail::invoked_identity<T, Arg>(arg);
58 }
59};
60
61} // end compute namespace
62} // end boost namespace
63
64#endif // BOOST_COMPUTE_FUNCTIONAL_IDENTITY_HPP