]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/spirit/home/x3/support/subcontext.hpp
db8e7a9f788a34aac6b9e30aafb50652a3b0eb9e
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / support / subcontext.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 Copyright (c) 2013 Agustín Bergé
4 http://spirit.sourceforge.net/
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM)
10 #define BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM
11
12 #include <boost/spirit/home/x3/support/context.hpp>
13 #include <boost/spirit/home/x3/support/unused.hpp>
14
15 namespace boost { namespace spirit { namespace x3
16 {
17 template <typename... T>
18 struct subcontext;
19
20 template <>
21 struct subcontext<>
22 {
23 template <typename Context>
24 subcontext(Context const& /*context*/)
25 {}
26
27 template <typename ID_>
28 unused_type
29 get(ID_) const
30 {
31 return unused;
32 }
33 };
34
35 template <typename T>
36 struct subcontext<T>
37 : context<typename T::first_type, typename T::second_type>
38 {
39 typedef context<
40 typename T::first_type, typename T::second_type
41 > context_type;
42
43 template <typename Context>
44 subcontext(Context const& context)
45 : context_type(x3::get<typename T::first_type>(context))
46 {}
47
48 using context_type::get;
49 };
50
51 template <typename T, typename... Tail>
52 struct subcontext<T, Tail...>
53 : subcontext<Tail...>
54 , context<
55 typename T::first_type, typename T::second_type
56 , subcontext<Tail...>
57 >
58 {
59 typedef subcontext<Tail...> base_type;
60 typedef context<
61 typename T::first_type, typename T::second_type
62 , base_type
63 > context_type;
64
65 template <typename Context>
66 subcontext(Context const& context)
67 : base_type(context)
68 , context_type(
69 x3::get<typename T::first_type>(context)
70 , *static_cast<base_type*>(this))
71 {}
72
73 using context_type::get;
74 };
75
76 }}}
77
78 #endif