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_FUNCTIONAL_AS_HPP
12 #define BOOST_COMPUTE_FUNCTIONAL_AS_HPP
13 
14 namespace boost {
15 namespace compute {
16 namespace detail {
17 
18 template<class T, class Arg>
19 struct invoked_as
20 {
invoked_asboost::compute::detail::invoked_as21     invoked_as(const Arg &arg)
22         : m_arg(arg)
23     {
24     }
25 
26     Arg m_arg;
27 };
28 
29 } // end detail namespace
30 
31 /// The \ref as function converts its argument to type \c T (similar to
32 /// reinterpret_cast<T>).
33 ///
34 /// \see \ref convert "convert<T>"
35 template<class T>
36 struct as
37 {
38     typedef T result_type;
39 
40     /// \internal_
41     template<class Arg>
operator ()boost::compute::as42     detail::invoked_as<T, Arg> operator()(const Arg &arg) const
43     {
44         return detail::invoked_as<T, Arg>(arg);
45     }
46 };
47 
48 } // end compute namespace
49 } // end boost namespace
50 
51 #endif // BOOST_COMPUTE_FUNCTIONAL_AS_HPP
52