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_SET_11062014_2121
8 #define FUSION_AS_SET_11062014_2121
9 
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/container/set/set_fwd.hpp>
12 
13 ///////////////////////////////////////////////////////////////////////////////
14 // Without variadics, we will use the PP version
15 ///////////////////////////////////////////////////////////////////////////////
16 #if !defined(BOOST_FUSION_HAS_VARIADIC_SET)
17 # include <boost/fusion/container/set/detail/cpp03/as_set.hpp>
18 #else
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 // C++11 interface
22 ///////////////////////////////////////////////////////////////////////////////
23 #include <boost/fusion/support/detail/index_sequence.hpp>
24 #include <boost/fusion/container/set/set.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 
30 namespace boost { namespace fusion { namespace detail
31 {
32 BOOST_FUSION_BARRIER_BEGIN
33 
34     template <int size
35             , typename = typename detail::make_index_sequence<size>::type>
36     struct as_set;
37 
38     template <int size, std::size_t ...Indices>
39     struct as_set<size, detail::index_sequence<Indices...> >
40     {
41         template <typename I>
42         struct apply
43         {
44             typedef set<
45                 typename result_of::value_of<
46                     typename result_of::advance_c<I, Indices>::type
47                 >::type...
48             > type;
49         };
50 
51         template <typename Iterator>
52         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
53         static typename apply<Iterator>::type
callboost::fusion::detail::as_set54         call(Iterator const& i)
55         {
56             typedef apply<Iterator> gen;
57             typedef typename gen::type result;
58             return result(*advance_c<Indices>(i)...);
59         }
60     };
61 
62 BOOST_FUSION_BARRIER_END
63 }}}
64 
65 #endif
66 #endif
67 
68