]>
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_DETAIL_MPL_VECTOR_TO_TUPLE_HPP | |
12 | #define BOOST_COMPUTE_DETAIL_MPL_VECTOR_TO_TUPLE_HPP | |
13 | ||
14 | #include <boost/mpl/copy.hpp> | |
15 | #include <boost/mpl/vector.hpp> | |
16 | #include <boost/tuple/tuple.hpp> | |
17 | #include <boost/fusion/include/mpl.hpp> | |
18 | #include <boost/fusion/adapted/boost_tuple.hpp> | |
19 | #include <boost/preprocessor/repetition.hpp> | |
20 | ||
21 | #include <boost/compute/config.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace compute { | |
25 | namespace detail { | |
26 | ||
27 | namespace mpl = boost::mpl; | |
28 | ||
29 | template<class Vector, size_t N> | |
30 | struct mpl_vector_to_tuple_impl; | |
31 | ||
32 | #define BOOST_COMPUTE_PRINT_ELEM(z, n, unused) \ | |
33 | typename mpl::at_c<Vector, n>::type | |
34 | ||
35 | #define BOOST_COMPUTE_VEC2TUP(z, n, unused) \ | |
36 | template<class Vector> \ | |
37 | struct mpl_vector_to_tuple_impl<Vector, n> \ | |
38 | { \ | |
39 | typedef typename \ | |
40 | boost::tuple< \ | |
41 | BOOST_PP_ENUM(n, BOOST_COMPUTE_PRINT_ELEM, ~) \ | |
42 | > type; \ | |
43 | }; | |
44 | ||
45 | BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_VEC2TUP, ~) | |
46 | ||
47 | #undef BOOST_COMPUTE_VEC2TUP | |
48 | #undef BOOST_COMPUTE_PRINT_ELEM | |
49 | ||
50 | // meta-function which converts a mpl::vector to a boost::tuple | |
51 | template<class Vector> | |
52 | struct mpl_vector_to_tuple | |
53 | { | |
54 | typedef typename | |
55 | mpl_vector_to_tuple_impl< | |
56 | Vector, | |
57 | mpl::size<Vector>::value | |
58 | >::type type; | |
59 | }; | |
60 | ||
61 | } // end detail namespace | |
62 | } // end compute namespace | |
63 | } // end boost namespace | |
64 | ||
65 | #endif // BOOST_COMPUTE_DETAIL_MPL_VECTOR_TO_TUPLE_HPP |