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_TYPED_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.hpp>
15 #include <boost/preprocessor/repetition/enum_params.hpp>
16 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
18 #include <boost/config.hpp>
20 #include <boost/utility/result_of.hpp>
22 #include <boost/fusion/support/detail/access.hpp>
23 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
24 #include <boost/fusion/sequence/intrinsic/size.hpp>
25 #include <boost/fusion/container/vector/vector.hpp>
26 #include <boost/fusion/container/vector/convert.hpp>
28 #include <boost/fusion/functional/adapter/limits.hpp>
29 #include <boost/fusion/functional/adapter/detail/access.hpp>
31 #if defined (BOOST_MSVC)
32 # pragma warning(push)
33 # pragma warning (disable: 4512) // assignment operator could not be generated.
37 namespace boost { namespace fusion
40 template <class Function, class Sequence> class unfused_typed;
42 //----- ---- --- -- - - - -
46 template <class Derived, class Function,
47 class Sequence, long Arity>
48 struct unfused_typed_impl;
51 template <class Function, class Sequence>
53 : public detail::unfused_typed_impl
54 < unfused_typed<Function,Sequence>, Function, Sequence,
55 result_of::size<Sequence>::value >
57 Function fnc_transformed;
59 template <class D, class F, class S, long A>
60 friend struct detail::unfused_typed_impl;
62 typedef typename detail::call_param<Function>::type func_const_fwd_t;
66 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
67 inline explicit unfused_typed(func_const_fwd_t f = Function())
72 #define BOOST_PP_FILENAME_1 <boost/fusion/functional/adapter/unfused_typed.hpp>
73 #define BOOST_PP_ITERATION_LIMITS (0,BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY)
74 #include BOOST_PP_ITERATE()
78 #if defined (BOOST_MSVC)
84 #if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE)
85 template<class F, class Seq>
86 struct result_of< boost::fusion::unfused_typed<F,Seq> const () >
87 : boost::fusion::unfused_typed<F,Seq>::template result<
88 boost::fusion::unfused_typed<F,Seq> const () >
90 template<class F, class Seq>
91 struct result_of< boost::fusion::unfused_typed<F,Seq>() >
92 : boost::fusion::unfused_typed<F,Seq>::template result<
93 boost::fusion::unfused_typed<F,Seq> () >
96 template<class F, class Seq>
97 struct tr1_result_of< boost::fusion::unfused_typed<F,Seq> const () >
98 : boost::fusion::unfused_typed<F,Seq>::template result<
99 boost::fusion::unfused_typed<F,Seq> const () >
101 template<class F, class Seq>
102 struct tr1_result_of< boost::fusion::unfused_typed<F,Seq>() >
103 : boost::fusion::unfused_typed<F,Seq>::template result<
104 boost::fusion::unfused_typed<F,Seq> () >
109 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_HPP_INCLUDED
110 #else // defined(BOOST_PP_IS_ITERATING)
111 ///////////////////////////////////////////////////////////////////////////////
113 // Preprocessor vertical repetition code
115 ///////////////////////////////////////////////////////////////////////////////
116 #define N BOOST_PP_ITERATION()
121 template <class Derived, class Function, class Sequence>
122 struct unfused_typed_impl<Derived,Function,Sequence,N>
124 typedef typename detail::qf_c<Function>::type function_c;
125 typedef typename detail::qf<Function>::type function;
126 typedef typename result_of::as_vector<Sequence>::type arg_vector_t;
131 typename call_param<typename result_of::value_at_c<s,i>::type>::type a##i
133 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
134 inline typename boost::result_of<
135 function_c(arg_vector_t &) >::type
136 operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const
139 arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));
143 return static_cast<Derived const *>(this)->fnc_transformed(arg);
146 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
147 inline typename boost::result_of<
148 function(arg_vector_t &) >::type
149 operator()(BOOST_PP_ENUM(N,M,arg_vector_t))
152 arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));
156 return static_cast<Derived *>(this)->fnc_transformed(arg);
161 template <typename Sig> struct result { typedef void type; };
163 template <class Self BOOST_PP_ENUM_TRAILING_PARAMS(N,typename T)>
164 struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
165 : boost::result_of< function_c(arg_vector_t &) >
168 template <class Self BOOST_PP_ENUM_TRAILING_PARAMS(N,typename T)>
169 struct result< Self (BOOST_PP_ENUM_PARAMS(N,T)) >
170 : boost::result_of< function(arg_vector_t &) >
174 } // namespace detail
177 #endif // defined(BOOST_PP_IS_ITERATING)