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_DETAIL_MPL_VECTOR_TO_TUPLE_HPP
12 #define BOOST_COMPUTE_DETAIL_MPL_VECTOR_TO_TUPLE_HPP
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>
21 #include <boost/compute/config.hpp>
27 namespace mpl = boost::mpl;
29 template<class Vector, size_t N>
30 struct mpl_vector_to_tuple_impl;
32 #define BOOST_COMPUTE_PRINT_ELEM(z, n, unused) \
33 typename mpl::at_c<Vector, n>::type
35 #define BOOST_COMPUTE_VEC2TUP(z, n, unused) \
36 template<class Vector> \
37 struct mpl_vector_to_tuple_impl<Vector, n> \
41 BOOST_PP_ENUM(n, BOOST_COMPUTE_PRINT_ELEM, ~) \
45 BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_VEC2TUP, ~)
47 #undef BOOST_COMPUTE_VEC2TUP
48 #undef BOOST_COMPUTE_PRINT_ELEM
50 // meta-function which converts a mpl::vector to a boost::tuple
51 template<class Vector>
52 struct mpl_vector_to_tuple
55 mpl_vector_to_tuple_impl<
57 mpl::size<Vector>::value
61 } // end detail namespace
62 } // end compute namespace
63 } // end boost namespace
65 #endif // BOOST_COMPUTE_DETAIL_MPL_VECTOR_TO_TUPLE_HPP