1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_FUNCTIONAL_GET_HPP
12 #define BOOST_COMPUTE_FUNCTIONAL_GET_HPP
16 #include <boost/compute/types/fundamental.hpp>
17 #include <boost/compute/type_traits/scalar_type.hpp>
23 // meta-function returning the result type for get<N>()
24 template<size_t N, class Arg>
25 struct get_result_type
27 typedef typename scalar_type<Arg>::type type;
30 template<size_t N, class Arg, class T>
33 typedef typename get_result_type<N, T>::type result_type;
35 invoked_get(const Arg &arg)
43 } // end detail namespace
45 /// Returns the \c N'th element of an aggregate type (e.g. scalarN,
46 /// pair, tuple, etc.).
48 /// \see \ref field "field<T>"
53 template<class> struct result;
56 template<class F, class Arg>
59 typedef typename detail::get_result_type<N, Arg>::type type;
64 N, Arg, typename boost::remove_cv<typename Arg::result_type>::type
65 > operator()(const Arg &arg) const
67 typedef typename boost::remove_cv<typename Arg::result_type>::type T;
69 return detail::invoked_get<N, Arg, T>(arg);
73 } // end compute namespace
74 } // end boost namespace
76 #endif // BOOST_COMPUTE_FUNCTIONAL_GET_HPP