File indexing completed on 2025-01-18 09:30:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_FUNCTIONAL_GET_HPP
0012 #define BOOST_COMPUTE_FUNCTIONAL_GET_HPP
0013
0014 #include <cstddef>
0015
0016 #include <boost/compute/types/fundamental.hpp>
0017 #include <boost/compute/type_traits/scalar_type.hpp>
0018
0019 namespace boost {
0020 namespace compute {
0021 namespace detail {
0022
0023
0024 template<size_t N, class Arg>
0025 struct get_result_type
0026 {
0027 typedef typename scalar_type<Arg>::type type;
0028 };
0029
0030 template<size_t N, class Arg, class T>
0031 struct invoked_get
0032 {
0033 typedef typename get_result_type<N, T>::type result_type;
0034
0035 invoked_get(const Arg &arg)
0036 : m_arg(arg)
0037 {
0038 }
0039
0040 Arg m_arg;
0041 };
0042
0043 }
0044
0045
0046
0047
0048
0049 template<size_t N>
0050 struct get
0051 {
0052
0053 template<class> struct result;
0054
0055
0056 template<class F, class Arg>
0057 struct result<F(Arg)>
0058 {
0059 typedef typename detail::get_result_type<N, Arg>::type type;
0060 };
0061
0062 template<class Arg>
0063 detail::invoked_get<
0064 N, Arg, typename boost::remove_cv<typename Arg::result_type>::type
0065 > operator()(const Arg &arg) const
0066 {
0067 typedef typename boost::remove_cv<typename Arg::result_type>::type T;
0068
0069 return detail::invoked_get<N, Arg, T>(arg);
0070 }
0071 };
0072
0073 }
0074 }
0075
0076 #endif