Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/fusion/view/nview/nview.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2009 Hartmut Kaiser | |
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 | |
8 #if !defined(BOOST_FUSION_NVIEW_SEP_23_2009_0948PM) | |
9 #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM | |
10 | |
11 #include <boost/mpl/size.hpp> | |
12 #include <boost/mpl/if.hpp> | |
13 #include <boost/mpl/vector_c.hpp> | |
14 #include <boost/utility/result_of.hpp> | |
15 | |
16 #include <boost/type_traits/remove_reference.hpp> | |
17 #include <boost/type_traits/add_reference.hpp> | |
18 #include <boost/type_traits/add_const.hpp> | |
19 | |
20 #include <boost/fusion/support/is_view.hpp> | |
21 #include <boost/fusion/support/category_of.hpp> | |
22 #include <boost/fusion/support/sequence_base.hpp> | |
23 #include <boost/fusion/container/vector.hpp> | |
24 #include <boost/fusion/view/transform_view.hpp> | |
25 | |
26 #include <boost/config.hpp> | |
27 | |
28 namespace boost { namespace fusion | |
29 { | |
30 namespace detail | |
31 { | |
32 struct addref | |
33 { | |
34 template<typename Sig> | |
35 struct result; | |
36 | |
37 template<typename U> | |
38 struct result<addref(U)> : add_reference<U> {}; | |
39 | |
40 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES | |
41 template <typename T> | |
42 typename add_reference<T>::type | |
43 operator()(T& x) const | |
44 { | |
45 return x; | |
46 } | |
47 #else | |
48 template <typename T> | |
49 typename result<addref(T)>::type | |
50 operator()(T&& x) const | |
51 { | |
52 return x; | |
53 } | |
54 #endif | |
55 }; | |
56 | |
57 struct addconstref | |
58 { | |
59 template<typename Sig> | |
60 struct result; | |
61 | |
62 template<typename U> | |
63 struct result<addconstref(U)> | |
64 : add_reference<typename add_const<U>::type> | |
65 {}; | |
66 | |
67 template <typename T> | |
68 typename add_reference<typename add_const<T>::type>::type | |
69 operator()(T& x) const | |
70 { | |
71 return x; | |
72 } | |
73 | |
74 template <typename T> | |
75 typename add_reference<typename add_const<T>::type>::type | |
76 operator()(T const& x) const | |
77 { | |
78 return x; | |
79 } | |
80 }; | |
81 } | |
82 | |
83 struct nview_tag; | |
84 struct random_access_traversal_tag; | |
85 struct fusion_sequence_tag; | |
86 | |
87 template<typename Sequence, typename Indicies> | |
88 struct nview | |
89 : sequence_base<nview<Sequence, Indicies> > | |
90 { | |
91 typedef nview_tag fusion_tag; | |
92 typedef fusion_sequence_tag tag; // this gets picked up by MPL | |
93 typedef random_access_traversal_tag category; | |
94 | |
95 typedef mpl::true_ is_view; | |
96 typedef Indicies index_type; | |
97 typedef typename mpl::size<Indicies>::type size; | |
98 | |
99 typedef typename mpl::if_< | |
100 is_const<Sequence>, detail::addconstref, detail::addref | |
101 >::type transform_type; | |
102 typedef transform_view<Sequence, transform_type> transform_view_type; | |
103 typedef typename result_of::as_vector<transform_view_type>::type | |
104 sequence_type; | |
105 | |
106 explicit nview(Sequence& val) | |
107 : seq(sequence_type(transform_view_type(val, transform_type()))) | |
108 {} | |
109 | |
110 sequence_type seq; | |
111 }; | |
112 | |
113 }} | |
114 | |
115 // define the nview() generator functions | |
116 #include <boost/fusion/view/nview/detail/nview_impl.hpp> | |
117 | |
118 #endif | |
119 | |
120 |