]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/support/subcontext.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / 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/fusion/support/pair.hpp>
13 #include <boost/spirit/home/x3/support/context.hpp>
14 #include <boost/spirit/home/x3/support/unused.hpp>
15
16 namespace boost { namespace spirit { namespace x3
17 {
18 template <typename... T>
19 struct subcontext;
20
21 template <>
22 struct subcontext<>
23 {
24 template <typename Context>
25 subcontext(Context const& /*context*/)
26 {}
27
28 template <typename ID_>
29 unused_type
30 get(ID_) const
31 {
32 return unused;
33 }
34 };
35
36 template <typename T>
37 struct subcontext<T>
38 : context<typename T::first_type, typename T::second_type>
39 {
40 typedef context<
41 typename T::first_type, typename T::second_type
42 > context_type;
43
44 template <typename Context>
45 subcontext(Context const& context)
46 : context_type(x3::get<typename T::first_type>(context))
47 {}
48
49 using context_type::get;
50 };
51
52 template <typename T, typename... Tail>
53 struct subcontext<T, Tail...>
54 : subcontext<Tail...>
55 , context<
56 typename T::first_type, typename T::second_type
57 , subcontext<Tail...>
58 >
59 {
60 typedef subcontext<Tail...> base_type;
61 typedef context<
62 typename T::first_type, typename T::second_type
63 , base_type
64 > context_type;
65
66 template <typename Context>
67 subcontext(Context const& context)
68 : base_type(context)
69 , context_type(
70 x3::get<typename T::first_type>(context)
71 , *static_cast<base_type*>(this))
72 {}
73
74 using context_type::get;
75 };
76
77 }}}
78
79 #endif