summaryrefslogtreecommitdiffstats
blob: 9121fdc8cfc44bce651fb493bc4f01b97e55ba5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*=============================================================================
    Copyright (c) 2001-2007 Joel de Guzman

    Distributed under the Boost Software License, Version 1.0. (See accompanying 
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef PHOENIX_BIND_BIND_FUNCTION_HPP
#define PHOENIX_BIND_BIND_FUNCTION_HPP

#include <boost/spirit/home/phoenix/core/compose.hpp>
#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp>
#include <boost/spirit/home/phoenix/bind/detail/function_ptr.hpp>

namespace boost { namespace phoenix
{
    template <typename RT>
    inline actor<
        typename as_composite<
            detail::function_eval<0>
          , detail::function_ptr<0, RT, RT(*)()>
        >::type>
    bind(RT(*f)())
    {
        typedef detail::function_ptr<0, RT, RT(*)()> fp_type;
        return compose<detail::function_eval<0> >(fp_type(f));
    }

    template <typename RT, typename T0, typename A0>
    inline actor<
        typename as_composite<
            detail::function_eval<1>
          , detail::function_ptr<1, RT, RT(*)(T0)>
          , A0
        >::type>
    bind(RT(*f)(T0), A0 const& _0)
    {
        typedef detail::function_ptr<1, RT, RT(*)(T0)> fp_type;
        return compose<detail::function_eval<1> >(fp_type(f), _0);
    }

    template <typename RT, typename T0, typename T1, typename A0, typename A1>
    inline actor<
        typename as_composite<
            detail::function_eval<2>
          , detail::function_ptr<2, RT, RT(*)(T0, T1)>
          , A0, A1
        >::type>
    bind(RT(*f)(T0, T1), A0 const& _0, A1 const& _1)
    {
        typedef detail::function_ptr<2, RT, RT(*)(T0, T1)> fp_type;
        return compose<detail::function_eval<2> >(fp_type(f), _0, _1);
    }

    //  Bring in the rest of the function binders
    #include <boost/spirit/home/phoenix/bind/detail/bind_function.hpp>
}}

#endif