]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/include/boost/metaparse/v1/impl/nth_of_c_impl.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / include / boost / metaparse / v1 / impl / nth_of_c_impl.hpp
1 #ifndef BOOST_METAPARSE_V1_IMPL_NTH_OF_C_IMPL_HPP
2 #define BOOST_METAPARSE_V1_IMPL_NTH_OF_C_IMPL_HPP
3
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/metaparse/v1/impl/skip_seq.hpp>
10
11 #include <boost/mpl/front.hpp>
12 #include <boost/mpl/pop_front.hpp>
13 #include <boost/mpl/fold.hpp>
14
15 namespace boost
16 {
17 namespace metaparse
18 {
19 namespace v1
20 {
21 namespace impl
22 {
23 template <int N, class Seq>
24 struct nth_of_c_impl
25 {
26 private:
27 template <class NextResult>
28 struct apply_unchecked :
29 nth_of_c_impl<
30 N - 1,
31 typename boost::mpl::pop_front<Seq>::type
32 >::template apply<
33 typename get_remaining<NextResult>::type,
34 typename get_position<NextResult>::type
35 >
36 {};
37 public:
38 typedef nth_of_c_impl type;
39
40 template <class S, class Pos>
41 struct apply :
42 boost::mpl::eval_if<
43 typename is_error<
44 typename boost::mpl::front<Seq>::type::template apply<S, Pos>
45 >::type,
46 typename boost::mpl::front<Seq>::type::template apply<S, Pos>,
47 apply_unchecked<
48 typename boost::mpl::front<Seq>::type::template apply<S, Pos>
49 >
50 >
51 {};
52 };
53
54 template <class Seq>
55 struct nth_of_c_impl<0, Seq>
56 {
57 typedef nth_of_c_impl type;
58
59 template <class S, class Pos>
60 struct apply :
61 boost::mpl::fold<
62 typename boost::mpl::pop_front<Seq>::type,
63 typename boost::mpl::front<Seq>::type::template apply<
64 S,
65 Pos
66 >::type,
67 skip_seq
68 >
69 {};
70 };
71 }
72 }
73 }
74 }
75
76 #endif
77