Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 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_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 // meta-function returning the result type for get<N>()
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 } // end detail namespace
0044 
0045 /// Returns the \c N'th element of an aggregate type (e.g. scalarN,
0046 /// pair, tuple, etc.).
0047 ///
0048 /// \see \ref field "field<T>"
0049 template<size_t N>
0050 struct get
0051 {
0052     /// \internal_
0053     template<class> struct result;
0054 
0055     /// \internal_
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 } // end compute namespace
0074 } // end boost namespace
0075 
0076 #endif // BOOST_COMPUTE_FUNCTIONAL_GET_HPP