Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2006-2007 Tobias Schwinger
|
Chris@16
|
3
|
Chris@16
|
4 Use modification and distribution are subject to the Boost Software
|
Chris@16
|
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt).
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8
|
Chris@16
|
9 #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_HPP_INCLUDED)
|
Chris@16
|
10 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_HPP_INCLUDED
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/type_traits/add_reference.hpp>
|
Chris@16
|
13 #include <boost/config.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/fusion/functional/adapter/detail/access.hpp>
|
Chris@16
|
16 #include <boost/fusion/functional/invocation/invoke.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 #if defined (BOOST_MSVC)
|
Chris@16
|
19 # pragma warning(push)
|
Chris@16
|
20 # pragma warning (disable: 4512) // assignment operator could not be generated.
|
Chris@16
|
21 #endif
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost { namespace fusion
|
Chris@16
|
24 {
|
Chris@16
|
25 template <typename Function> class fused;
|
Chris@16
|
26
|
Chris@16
|
27 //----- ---- --- -- - - - -
|
Chris@16
|
28
|
Chris@16
|
29 template <typename Function>
|
Chris@16
|
30 class fused
|
Chris@16
|
31 {
|
Chris@16
|
32 Function fnc_transformed;
|
Chris@16
|
33
|
Chris@16
|
34 typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
|
Chris@16
|
35 typedef typename detail::qf<Function>::type & func_fwd_t;
|
Chris@16
|
36
|
Chris@16
|
37 public:
|
Chris@16
|
38
|
Chris@16
|
39 inline explicit fused(func_const_fwd_t f = Function())
|
Chris@16
|
40 : fnc_transformed(f)
|
Chris@16
|
41 { }
|
Chris@16
|
42
|
Chris@16
|
43 template <class Seq>
|
Chris@16
|
44 inline typename result_of::invoke<func_const_fwd_t,Seq const>::type
|
Chris@16
|
45 operator()(Seq const & s) const
|
Chris@16
|
46 {
|
Chris@16
|
47 return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
|
Chris@16
|
48 }
|
Chris@16
|
49
|
Chris@16
|
50 template <class Seq>
|
Chris@16
|
51 inline typename result_of::invoke<func_fwd_t,Seq const>::type
|
Chris@16
|
52 operator()(Seq const & s)
|
Chris@16
|
53 {
|
Chris@16
|
54 return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
|
Chris@16
|
55 }
|
Chris@16
|
56
|
Chris@16
|
57 template <class Seq>
|
Chris@16
|
58 inline typename result_of::invoke<func_const_fwd_t,Seq>::type
|
Chris@16
|
59 operator()(Seq & s) const
|
Chris@16
|
60 {
|
Chris@16
|
61 return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
|
Chris@16
|
62 }
|
Chris@16
|
63
|
Chris@16
|
64 template <class Seq>
|
Chris@16
|
65 inline typename result_of::invoke<func_fwd_t,Seq>::type
|
Chris@16
|
66 operator()(Seq & s)
|
Chris@16
|
67 {
|
Chris@16
|
68 return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 template <typename Sig>
|
Chris@16
|
72 struct result;
|
Chris@16
|
73
|
Chris@16
|
74 template <class Self, class Seq>
|
Chris@16
|
75 struct result< Self const (Seq) >
|
Chris@16
|
76 : result_of::invoke<func_const_fwd_t,
|
Chris@16
|
77 typename boost::remove_reference<Seq>::type >
|
Chris@16
|
78 { };
|
Chris@16
|
79
|
Chris@16
|
80 template <class Self, class Seq>
|
Chris@16
|
81 struct result< Self(Seq) >
|
Chris@16
|
82 : result_of::invoke<func_fwd_t,
|
Chris@16
|
83 typename boost::remove_reference<Seq>::type >
|
Chris@16
|
84 { };
|
Chris@16
|
85
|
Chris@16
|
86 };
|
Chris@16
|
87
|
Chris@16
|
88 }}
|
Chris@16
|
89
|
Chris@16
|
90 #if defined (BOOST_MSVC)
|
Chris@16
|
91 # pragma warning(pop)
|
Chris@16
|
92 #endif
|
Chris@16
|
93
|
Chris@16
|
94 #endif
|
Chris@16
|
95
|