1 /*=============================================================================
2 Copyright (c) 2009 Hartmut Kaiser
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 ==============================================================================*/
8 #if !defined(BOOST_FUSION_NVIEW_SEP_23_2009_0948PM)
9 #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/mpl/if.hpp>
14 #include <boost/type_traits/add_reference.hpp>
15 #include <boost/type_traits/add_const.hpp>
17 #include <boost/fusion/support/is_view.hpp>
18 #include <boost/fusion/support/sequence_base.hpp>
19 #include <boost/fusion/container/vector.hpp>
20 #include <boost/fusion/sequence/intrinsic/size.hpp>
21 #include <boost/fusion/view/transform_view.hpp>
23 #include <boost/config.hpp>
25 namespace boost { namespace fusion
31 template<typename Sig>
35 struct result<addref(U)> : add_reference<U> {};
37 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
39 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
40 typename add_reference<T>::type
41 operator()(T& x) const
47 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
48 typename result<addref(T)>::type
49 operator()(T&& x) const
58 template<typename Sig>
62 struct result<addconstref(U)>
63 : add_reference<typename add_const<U>::type>
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
68 typename add_reference<typename add_const<T>::type>::type
69 operator()(T& x) const
75 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
76 typename add_reference<typename add_const<T>::type>::type
77 operator()(T const& x) const
85 struct random_access_traversal_tag;
86 struct fusion_sequence_tag;
88 template<typename Sequence, typename Indicies>
90 : sequence_base<nview<Sequence, Indicies> >
92 typedef nview_tag fusion_tag;
93 typedef fusion_sequence_tag tag; // this gets picked up by MPL
94 typedef random_access_traversal_tag category;
96 typedef mpl::true_ is_view;
97 typedef Indicies index_type;
98 typedef typename result_of::size<Indicies>::type size;
100 typedef typename mpl::if_<
101 is_const<Sequence>, detail::addconstref, detail::addref
102 >::type transform_type;
103 typedef transform_view<Sequence, transform_type> transform_view_type;
104 typedef typename result_of::as_vector<transform_view_type>::type
107 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
108 explicit nview(Sequence& val)
109 : seq(sequence_type(transform_view_type(val, transform_type())))
117 // define the nview() generator functions
118 #include <boost/fusion/view/nview/detail/nview_impl.hpp>