Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2006-2007 Tobias Schwinger
|
Chris@16
|
3
|
Chris@16
|
4 Use modification and distribution are subject to the Boost Software
|
Chris@16
|
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt).
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8
|
Chris@16
|
9 #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED)
|
Chris@16
|
10 #if !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
13 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
14 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
15 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
16 #include <boost/preprocessor/facilities/intercept.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/utility/result_of.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/config.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/fusion/container/vector/vector.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/fusion/functional/adapter/limits.hpp>
|
Chris@16
|
25 #include <boost/fusion/functional/adapter/detail/access.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #if defined (BOOST_MSVC)
|
Chris@16
|
28 # pragma warning(push)
|
Chris@16
|
29 # pragma warning (disable: 4512) // assignment operator could not be generated.
|
Chris@16
|
30 #endif
|
Chris@16
|
31
|
Chris@16
|
32 namespace boost { namespace fusion
|
Chris@16
|
33 {
|
Chris@16
|
34 template <class Function, bool AllowNullary = true>
|
Chris@16
|
35 class unfused;
|
Chris@16
|
36
|
Chris@16
|
37 //----- ---- --- -- - - - -
|
Chris@16
|
38
|
Chris@16
|
39 template <class Function>
|
Chris@16
|
40 class unfused<Function,true>
|
Chris@16
|
41 : public unfused<Function,false>
|
Chris@16
|
42 {
|
Chris@16
|
43 typedef typename detail::qf_c<Function>::type function_c;
|
Chris@16
|
44 typedef typename detail::qf<Function>::type function;
|
Chris@16
|
45 typedef typename detail::call_param<Function>::type func_const_fwd_t;
|
Chris@16
|
46 public:
|
Chris@16
|
47
|
Chris@16
|
48 using unfused<Function,false>::operator();
|
Chris@16
|
49
|
Chris@101
|
50 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
51 inline explicit unfused(func_const_fwd_t f = function())
|
Chris@16
|
52 : unfused<Function,false>(f)
|
Chris@16
|
53 { }
|
Chris@16
|
54
|
Chris@16
|
55 typedef typename boost::result_of<
|
Chris@16
|
56 function_c(fusion::vector0<> &) >::type call_const_0_result;
|
Chris@16
|
57
|
Chris@101
|
58 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
59 inline call_const_0_result operator()() const
|
Chris@16
|
60 {
|
Chris@16
|
61 fusion::vector0<> arg;
|
Chris@16
|
62 return this->fnc_transformed(arg);
|
Chris@16
|
63 }
|
Chris@16
|
64
|
Chris@16
|
65 typedef typename boost::result_of<
|
Chris@16
|
66 function(fusion::vector0<> &) >::type call_0_result;
|
Chris@16
|
67
|
Chris@101
|
68 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@101
|
69 inline call_0_result operator()()
|
Chris@16
|
70 {
|
Chris@16
|
71 fusion::vector0<> arg;
|
Chris@16
|
72 return this->fnc_transformed(arg);
|
Chris@16
|
73 }
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76 template <class Function> class unfused<Function,false>
|
Chris@16
|
77 {
|
Chris@16
|
78 protected:
|
Chris@16
|
79 Function fnc_transformed;
|
Chris@16
|
80 typedef typename detail::qf_c<Function>::type function_c;
|
Chris@16
|
81 typedef typename detail::qf<Function>::type function;
|
Chris@16
|
82 typedef typename detail::call_param<Function>::type func_const_fwd_t;
|
Chris@16
|
83 public:
|
Chris@16
|
84
|
Chris@101
|
85 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
86 inline explicit unfused(func_const_fwd_t f = function())
|
Chris@16
|
87 : fnc_transformed(f)
|
Chris@16
|
88 { }
|
Chris@16
|
89
|
Chris@16
|
90 template <typename Sig>
|
Chris@16
|
91 struct result;
|
Chris@16
|
92
|
Chris@16
|
93 #define BOOST_PP_FILENAME_1 \
|
Chris@16
|
94 <boost/fusion/functional/adapter/unfused.hpp>
|
Chris@16
|
95 #define BOOST_PP_ITERATION_LIMITS \
|
Chris@16
|
96 (1,BOOST_FUSION_UNFUSED_MAX_ARITY)
|
Chris@16
|
97 #include BOOST_PP_ITERATE()
|
Chris@16
|
98 };
|
Chris@16
|
99 }}
|
Chris@16
|
100
|
Chris@16
|
101 #if defined (BOOST_MSVC)
|
Chris@16
|
102 # pragma warning(pop)
|
Chris@16
|
103 #endif
|
Chris@16
|
104
|
Chris@16
|
105 namespace boost
|
Chris@16
|
106 {
|
Chris@16
|
107 #if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE)
|
Chris@16
|
108 template<class F>
|
Chris@16
|
109 struct result_of< boost::fusion::unfused<F> const () >
|
Chris@16
|
110 {
|
Chris@16
|
111 typedef typename boost::fusion::unfused<F>::call_const_0_result type;
|
Chris@16
|
112 };
|
Chris@16
|
113 template<class F>
|
Chris@16
|
114 struct result_of< boost::fusion::unfused<F>() >
|
Chris@16
|
115 {
|
Chris@16
|
116 typedef typename boost::fusion::unfused<F>::call_0_result type;
|
Chris@16
|
117 };
|
Chris@16
|
118 #endif
|
Chris@16
|
119 template<class F>
|
Chris@16
|
120 struct tr1_result_of< boost::fusion::unfused<F> const () >
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef typename boost::fusion::unfused<F>::call_const_0_result type;
|
Chris@16
|
123 };
|
Chris@16
|
124 template<class F>
|
Chris@16
|
125 struct tr1_result_of< boost::fusion::unfused<F>() >
|
Chris@16
|
126 {
|
Chris@16
|
127 typedef typename boost::fusion::unfused<F>::call_0_result type;
|
Chris@16
|
128 };
|
Chris@16
|
129 }
|
Chris@16
|
130
|
Chris@16
|
131 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED
|
Chris@16
|
132 #else // defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
133 ////////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
134 //
|
Chris@16
|
135 // Preprocessor vertical repetition code
|
Chris@16
|
136 //
|
Chris@16
|
137 ////////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
138 #define N BOOST_PP_ITERATION()
|
Chris@16
|
139
|
Chris@16
|
140 template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
Chris@16
|
141 struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
|
Chris@16
|
142 : boost::result_of< function_c(
|
Chris@16
|
143 BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
Chris@16
|
144 typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
|
Chris@16
|
145 { };
|
Chris@16
|
146
|
Chris@16
|
147 template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
Chris@16
|
148 struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
|
Chris@16
|
149 : boost::result_of< function(
|
Chris@16
|
150 BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
Chris@16
|
151 typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
|
Chris@16
|
152 { };
|
Chris@16
|
153
|
Chris@16
|
154 template <BOOST_PP_ENUM_PARAMS(N,typename T)>
|
Chris@101
|
155 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
156 inline typename boost::result_of<function_c(BOOST_PP_CAT(fusion::vector,N)
|
Chris@16
|
157 <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
|
Chris@16
|
158 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
|
Chris@16
|
159 {
|
Chris@16
|
160 BOOST_PP_CAT(fusion::vector,N)<
|
Chris@16
|
161 BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
|
Chris@16
|
162 arg(BOOST_PP_ENUM_PARAMS(N,a));
|
Chris@16
|
163 return this->fnc_transformed(arg);
|
Chris@16
|
164 }
|
Chris@16
|
165
|
Chris@16
|
166 template <BOOST_PP_ENUM_PARAMS(N,typename T)>
|
Chris@101
|
167 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
168 inline typename boost::result_of<function(BOOST_PP_CAT(fusion::vector,N)
|
Chris@16
|
169 <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
|
Chris@16
|
170 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a))
|
Chris@16
|
171 {
|
Chris@16
|
172 BOOST_PP_CAT(fusion::vector,N)<
|
Chris@16
|
173 BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
|
Chris@16
|
174 arg(BOOST_PP_ENUM_PARAMS(N,a));
|
Chris@16
|
175 return this->fnc_transformed(arg);
|
Chris@16
|
176 }
|
Chris@16
|
177 #undef N
|
Chris@16
|
178 #endif // defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
179 #endif
|
Chris@16
|
180
|