Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:01

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_FUNCTIONAL_IDENTITY_HPP
0012 #define BOOST_COMPUTE_FUNCTIONAL_IDENTITY_HPP
0013 
0014 namespace boost {
0015 namespace compute {
0016 namespace detail {
0017 
0018 template<class T, class Arg>
0019 struct invoked_identity
0020 {
0021     typedef T result_type;
0022 
0023     invoked_identity(const Arg &arg)
0024         : m_arg(arg)
0025     {
0026     }
0027 
0028     Arg m_arg;
0029 };
0030 
0031 } // end detail namespace
0032 
0033 /// Identity function which simply returns its input.
0034 ///
0035 /// For example, to directly copy values using the transform() algorithm:
0036 /// \code
0037 /// transform(input.begin(), input.end(), output.begin(), identity<int>(), queue);
0038 /// \endcode
0039 ///
0040 /// \see \ref as "as<T>", \ref convert "convert<T>"
0041 template<class T>
0042 class identity
0043 {
0044 public:
0045     /// Identity function result type.
0046     typedef T result_type;
0047 
0048     /// Creates a new identity function.
0049     identity()
0050     {
0051     }
0052 
0053     /// \internal_
0054     template<class Arg>
0055     detail::invoked_identity<T, Arg> operator()(const Arg &arg) const
0056     {
0057         return detail::invoked_identity<T, Arg>(arg);
0058     }
0059 };
0060 
0061 } // end compute namespace
0062 } // end boost namespace
0063 
0064 #endif // BOOST_COMPUTE_FUNCTIONAL_IDENTITY_HPP