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