]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/functional/get.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / functional / get.hpp
CommitLineData
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_GET_HPP
12#define BOOST_COMPUTE_FUNCTIONAL_GET_HPP
13
14#include <cstddef>
15
16#include <boost/compute/types/fundamental.hpp>
17#include <boost/compute/type_traits/scalar_type.hpp>
18
19namespace boost {
20namespace compute {
21namespace detail {
22
23// meta-function returning the result type for get<N>()
24template<size_t N, class Arg>
25struct get_result_type
26{
27 typedef typename scalar_type<Arg>::type type;
28};
29
30template<size_t N, class Arg, class T>
31struct invoked_get
32{
33 typedef typename get_result_type<N, T>::type result_type;
34
35 invoked_get(const Arg &arg)
36 : m_arg(arg)
37 {
38 }
39
40 Arg m_arg;
41};
42
43} // end detail namespace
44
45/// Returns the \c N'th element of an aggregate type (e.g. scalarN,
46/// pair, tuple, etc.).
47///
48/// \see \ref field "field<T>"
49template<size_t N>
50struct get
51{
52 /// \internal_
53 template<class> struct result;
54
55 /// \internal_
56 template<class F, class Arg>
57 struct result<F(Arg)>
58 {
59 typedef typename detail::get_result_type<N, Arg>::type type;
60 };
61
62 template<class Arg>
63 detail::invoked_get<
64 N, Arg, typename boost::remove_cv<typename Arg::result_type>::type
65 > operator()(const Arg &arg) const
66 {
67 typedef typename boost::remove_cv<typename Arg::result_type>::type T;
68
69 return detail::invoked_get<N, Arg, T>(arg);
70 }
71};
72
73} // end compute namespace
74} // end boost namespace
75
76#endif // BOOST_COMPUTE_FUNCTIONAL_GET_HPP