summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/support/utility/lambda_visitor.hpp
blob: 83e1d2f0466015b788973ab1caf7463a19402ab0 (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
/*=============================================================================
    Copyright (c) 2014 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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM)
#define BOOST_SPIRIT_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM

namespace boost { namespace spirit { namespace x3
{
    template <typename RT, typename... Lambdas>
    struct lambda_visitor;

    template <typename RT, typename F, typename... Lambdas>
    struct lambda_visitor<RT, F, Lambdas...> : F, lambda_visitor<RT, Lambdas...>
    {
        typedef lambda_visitor<RT , Lambdas...> base_type;
        using F::operator();
        using base_type::operator();
        lambda_visitor(F f, Lambdas... lambdas)
          : F(f), base_type(lambdas...)
        {}
    };

    template <typename RT, typename F>
    struct lambda_visitor<RT, F> : F
    {
        typedef RT result_type;
        using F::operator();
        lambda_visitor(F f)
          : F(f)
        {}
    };

    template <typename RT>
    struct lambda_visitor<RT>
    {
        typedef RT result_type;
    };

    template <typename RT, typename... Lambdas>
    lambda_visitor<RT, Lambdas...> make_lambda_visitor(Lambdas... lambdas)
    {
        return { lambdas... };
    }
}}}

#endif