1 /*=============================================================================
2 Copyright (c) 2006-2007 Tobias Schwinger
4 Use modification and distribution are subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7 ==============================================================================*/
9 #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED)
10 #if !defined(BOOST_PP_IS_ITERATING)
12 #include <boost/preprocessor/cat.hpp>
13 #include <boost/preprocessor/iteration/iterate.hpp>
14 #include <boost/preprocessor/repetition/enum_params.hpp>
15 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
16 #include <boost/preprocessor/facilities/intercept.hpp>
18 #include <boost/utility/result_of.hpp>
20 #include <boost/config.hpp>
22 #include <boost/fusion/container/vector/vector.hpp>
24 #include <boost/fusion/functional/adapter/limits.hpp>
25 #include <boost/fusion/functional/adapter/detail/access.hpp>
27 #if defined (BOOST_MSVC)
28 # pragma warning(push)
29 # pragma warning (disable: 4512) // assignment operator could not be generated.
32 namespace boost { namespace fusion
34 template <class Function, bool AllowNullary = true>
37 //----- ---- --- -- - - - -
39 template <class Function>
40 class unfused<Function,true>
41 : public unfused<Function,false>
43 typedef typename detail::qf_c<Function>::type function_c;
44 typedef typename detail::qf<Function>::type function;
45 typedef typename detail::call_param<Function>::type func_const_fwd_t;
48 using unfused<Function,false>::operator();
50 BOOST_FUSION_GPU_ENABLED inline explicit unfused(func_const_fwd_t f = function())
51 : unfused<Function,false>(f)
54 typedef typename boost::result_of<
55 function_c(fusion::vector0<> &) >::type call_const_0_result;
57 BOOST_FUSION_GPU_ENABLED inline call_const_0_result operator()() const
59 fusion::vector0<> arg;
60 return this->fnc_transformed(arg);
63 typedef typename boost::result_of<
64 function(fusion::vector0<> &) >::type call_0_result;
66 BOOST_FUSION_GPU_ENABLED inline call_0_result operator()()
68 fusion::vector0<> arg;
69 return this->fnc_transformed(arg);
73 template <class Function> class unfused<Function,false>
76 Function fnc_transformed;
77 typedef typename detail::qf_c<Function>::type function_c;
78 typedef typename detail::qf<Function>::type function;
79 typedef typename detail::call_param<Function>::type func_const_fwd_t;
82 BOOST_FUSION_GPU_ENABLED
83 inline explicit unfused(func_const_fwd_t f = function())
87 template <typename Sig>
90 #define BOOST_PP_FILENAME_1 \
91 <boost/fusion/functional/adapter/unfused.hpp>
92 #define BOOST_PP_ITERATION_LIMITS \
93 (1,BOOST_FUSION_UNFUSED_MAX_ARITY)
94 #include BOOST_PP_ITERATE()
98 #if defined (BOOST_MSVC)
104 #if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE)
106 struct result_of< boost::fusion::unfused<F> const () >
108 typedef typename boost::fusion::unfused<F>::call_const_0_result type;
111 struct result_of< boost::fusion::unfused<F>() >
113 typedef typename boost::fusion::unfused<F>::call_0_result type;
117 struct tr1_result_of< boost::fusion::unfused<F> const () >
119 typedef typename boost::fusion::unfused<F>::call_const_0_result type;
122 struct tr1_result_of< boost::fusion::unfused<F>() >
124 typedef typename boost::fusion::unfused<F>::call_0_result type;
128 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED
129 #else // defined(BOOST_PP_IS_ITERATING)
130 ////////////////////////////////////////////////////////////////////////////////
132 // Preprocessor vertical repetition code
134 ////////////////////////////////////////////////////////////////////////////////
135 #define N BOOST_PP_ITERATION()
137 template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
138 struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
139 : boost::result_of< function_c(
140 BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
141 typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
144 template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
145 struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
146 : boost::result_of< function(
147 BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
148 typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
151 template <BOOST_PP_ENUM_PARAMS(N,typename T)>
152 BOOST_FUSION_GPU_ENABLED
153 inline typename boost::result_of<function_c(BOOST_PP_CAT(fusion::vector,N)
154 <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
155 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
157 BOOST_PP_CAT(fusion::vector,N)<
158 BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
159 arg(BOOST_PP_ENUM_PARAMS(N,a));
160 return this->fnc_transformed(arg);
163 template <BOOST_PP_ENUM_PARAMS(N,typename T)>
164 BOOST_FUSION_GPU_ENABLED
165 inline typename boost::result_of<function(BOOST_PP_CAT(fusion::vector,N)
166 <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
167 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a))
169 BOOST_PP_CAT(fusion::vector,N)<
170 BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
171 arg(BOOST_PP_ENUM_PARAMS(N,a));
172 return this->fnc_transformed(arg);
175 #endif // defined(BOOST_PP_IS_ITERATING)