PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/phoenix/bind/detail/function_ptr.hpp

http://hadesmem.googlecode.com/
C++ Header | 99 lines | 69 code | 19 blank | 11 comment | 0 complexity | f34d453dcba4ec90dac0c4bf8f33c130 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2007 Joel de Guzman
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#if !defined(BOOST_PP_IS_ITERATING)
 8#if !defined(PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP)
 9#define PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP
10
11#include <boost/preprocessor/iterate.hpp>
12#include <boost/preprocessor/repetition/enum_params.hpp>
13#include <boost/preprocessor/repetition/enum_binary_params.hpp>
14#include <boost/preprocessor/dec.hpp>
15
16namespace boost { namespace phoenix { namespace detail
17{
18    template <int N>
19    struct function_ptr_impl
20    {
21        template <typename RT, typename FP>
22        struct impl;
23    };
24
25    template <int N, typename RT, typename FP>
26    struct function_ptr : function_ptr_impl<N>::template impl<RT, FP>
27    {
28        typedef typename function_ptr_impl<N>::template impl<RT, FP> base;
29        function_ptr(FP fp)
30            : base(fp) {}
31    };
32
33    template <>
34    struct function_ptr_impl<0>
35    {
36        template <typename RT, typename FP>
37        struct impl
38        {
39            typedef RT result_type;
40
41            impl(FP fp)
42                : fp(fp) {}
43
44            RT operator()() const
45            {
46                return fp();
47            }
48
49            FP fp;
50        };
51    };
52
53#define BOOST_PP_ITERATION_PARAMS_1                                             \
54    (3, (1, PHOENIX_COMPOSITE_LIMIT,                                            \
55    "boost/spirit/home/phoenix/bind/detail/function_ptr.hpp"))
56#include BOOST_PP_ITERATE()
57
58}}} // namespace boost::phoenix::detail
59
60#endif
61
62///////////////////////////////////////////////////////////////////////////////
63//
64//  Preprocessor vertical repetition code
65//
66///////////////////////////////////////////////////////////////////////////////
67#else // defined(BOOST_PP_IS_ITERATING)
68
69#define N BOOST_PP_ITERATION()
70
71    template <>
72    struct function_ptr_impl<N>
73    {
74        template <typename RT, typename FP>
75        struct impl
76        {
77            template <BOOST_PP_ENUM_PARAMS(N, typename T)>
78            struct result
79            {
80                typedef RT type;
81            };
82
83            impl(FP fp)
84                : fp(fp) {}
85
86            template <BOOST_PP_ENUM_PARAMS(N, typename A)>
87            RT operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) const
88            {
89                return fp(BOOST_PP_ENUM_PARAMS(N, _));
90            }
91
92            FP fp;
93        };
94    };
95
96#undef N
97#endif // defined(BOOST_PP_IS_ITERATING)
98
99