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