Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / fusion / functional / adapter / fused.hpp
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_HPP_INCLUDED)
10 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_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.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 <typename Function> class fused;
27
28     //----- ---- --- -- - -  -   -
29
30     template <typename Function>
31     class fused
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_FUSION_GPU_ENABLED
41         inline explicit fused(func_const_fwd_t f = Function())
42             : fnc_transformed(f)
43         { }
44
45         template <class Seq> 
46         BOOST_FUSION_GPU_ENABLED
47         inline typename result_of::invoke<func_const_fwd_t,Seq const>::type 
48         operator()(Seq const & s) const
49         {
50             return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
51         }
52
53         template <class Seq> 
54         BOOST_FUSION_GPU_ENABLED
55         inline typename result_of::invoke<func_fwd_t,Seq const>::type 
56         operator()(Seq const & s) 
57         {
58             return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
59         }
60
61         template <class Seq> 
62         BOOST_FUSION_GPU_ENABLED
63         inline typename result_of::invoke<func_const_fwd_t,Seq>::type 
64         operator()(Seq & s) const
65         {
66             return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
67         }
68
69         template <class Seq> 
70         BOOST_FUSION_GPU_ENABLED
71         inline typename result_of::invoke<func_fwd_t,Seq>::type 
72         operator()(Seq & s) 
73         {
74             return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
75         }
76
77         template <typename Sig>
78         struct result;
79
80         template <class Self, class Seq>
81         struct result< Self const (Seq) >
82             : result_of::invoke<func_const_fwd_t,
83                 typename boost::remove_reference<Seq>::type >
84         { };
85
86         template <class Self, class Seq>
87         struct result< Self(Seq) >
88             : result_of::invoke<func_fwd_t,
89                 typename boost::remove_reference<Seq>::type >
90         { };
91
92     };
93
94 }}
95
96 #if defined (BOOST_MSVC)
97 #  pragma warning(pop)
98 #endif
99
100 #endif
101