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_FUSED_FUNCTION_OBJECT_HPP_INCLUDED)
10 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_FUNCTION_OBJECT_HPP_INCLUDED
11 
12 #include <boost/fusion/support/config.hpp>
13 #include <boost/type_traits/add_reference.hpp>
14 #include <boost/config.hpp>
15 
16 #include <boost/fusion/functional/adapter/detail/access.hpp>
17 #include <boost/fusion/functional/invocation/invoke_function_object.hpp>
18 
19 #if defined (BOOST_MSVC)
20 #  pragma warning(push)
21 #  pragma warning (disable: 4512) // assignment operator could not be generated.
22 #endif
23 
24 namespace boost { namespace fusion
25 {
26     template <class Function> class fused_function_object;
27 
28     //----- ---- --- -- - -  -   -
29 
30     template <class Function>
31     class fused_function_object
32     {
33         Function fnc_transformed;
34 
35         typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
36         typedef typename detail::qf<Function>::type & func_fwd_t;
37 
38     public:
39 
40         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
fused_function_object(func_const_fwd_t f=Function ())41         inline explicit fused_function_object(func_const_fwd_t f = Function())
42             : fnc_transformed(f)
43         { }
44 
45         template <class Seq>
46         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
47         inline typename result_of::invoke_function_object<func_const_fwd_t,
operator ()(Seq const & s) const48             Seq const>::type operator()(Seq const & s) const
49         {
50           return fusion::invoke_function_object<
51               func_const_fwd_t >(this->fnc_transformed,s);
52         }
53 
54         template <class Seq>
55         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
56         inline typename result_of::invoke_function_object<func_fwd_t,
57             Seq const>::type
operator ()(Seq const & s)58         operator()(Seq const & s)
59         {
60           return fusion::invoke_function_object<
61               func_fwd_t >(this->fnc_transformed,s);
62         }
63 
64         template <class Seq>
65         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
66         inline typename result_of::invoke_function_object<func_const_fwd_t,
67             Seq>::type
operator ()(Seq & s) const68         operator()(Seq & s) const
69         {
70           return fusion::invoke_function_object<
71               func_const_fwd_t >(this->fnc_transformed,s);
72         }
73 
74         template <class Seq>
75         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
76         inline typename result_of::invoke_function_object<func_fwd_t,Seq>::type
operator ()(Seq & s)77         operator()(Seq & s)
78         {
79           return fusion::invoke_function_object<
80               func_fwd_t >(this->fnc_transformed,s);
81         }
82 
83         template <typename Sig>
84         struct result;
85 
86         template <class Self, class Seq>
87         struct result< Self const (Seq) >
88             : result_of::invoke_function_object<func_const_fwd_t,
89                 typename boost::remove_reference<Seq>::type >
90         { };
91 
92         template <class Self, class Seq>
93         struct result< Self(Seq) >
94             : result_of::invoke_function_object<func_fwd_t,
95                 typename boost::remove_reference<Seq>::type >
96         { };
97     };
98 
99 }}
100 
101 #if defined (BOOST_MSVC)
102 #  pragma warning(pop)
103 #endif
104 
105 #endif
106 
107