1/*=============================================================================
2 Copyright (c) 2014-2015 Kohei Takahashi
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7#ifndef FUSION_AS_VECTOR_11052014_1801
8#define FUSION_AS_VECTOR_11052014_1801
9
10#include <boost/fusion/support/config.hpp>
11#include <boost/fusion/container/vector/detail/config.hpp>
12
13///////////////////////////////////////////////////////////////////////////////
14// Without variadics, we will use the PP version
15///////////////////////////////////////////////////////////////////////////////
16#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
17# include <boost/fusion/container/vector/detail/cpp03/as_vector.hpp>
18#else
19
20///////////////////////////////////////////////////////////////////////////////
21// C++11 interface
22///////////////////////////////////////////////////////////////////////////////
23#include <boost/fusion/support/detail/index_sequence.hpp>
24#include <boost/fusion/container/vector/vector.hpp>
25#include <boost/fusion/iterator/value_of.hpp>
26#include <boost/fusion/iterator/deref.hpp>
27#include <boost/fusion/iterator/advance.hpp>
28#include <cstddef>
29
30namespace boost { namespace fusion { namespace detail
31{
32BOOST_FUSION_BARRIER_BEGIN
33
34 template <typename Indices>
35 struct as_vector_impl;
36
37 template <std::size_t ...Indices>
38 struct as_vector_impl<index_sequence<Indices...> >
39 {
40 template <typename Iterator>
41 struct apply
42 {
43 typedef vector<
44 typename result_of::value_of<
45 typename result_of::advance_c<Iterator, Indices>::type
46 >::type...
47 > type;
48 };
49
50 template <typename Iterator>
51 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
52 static typename apply<Iterator>::type
53 call(Iterator i)
54 {
55 typedef typename apply<Iterator>::type result;
56 return result(*advance_c<Indices>(i)...);
57 }
58 };
59
60 template <int size>
61 struct as_vector
62 : as_vector_impl<typename make_index_sequence<size>::type> {};
63
64BOOST_FUSION_BARRIER_END
65}}}
66
67#endif
68#endif
69
70
71