]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/next_line.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / next_line.qbk
1 [#next_line]
2 [section next_line]
3
4 [h1 Synopsis]
5
6 template <class SourcePosition, class Ch>
7 struct next_line;
8
9 This is a [link lazy_metafunction lazy template metafunction].
10
11 [table Arguments
12 [[Name] [Type]]
13 [[`SourcePosition`] [[link source_position source position]]]
14 [[`Ch`] [[link boxed_value boxed] character value. The character `SourcePosition` points to in the input.]]
15 ]
16
17 [h1 Description]
18
19 Returns a new source position, pointing to the beginning of the next line.
20
21 [h1 Header]
22
23 #include <boost/metaparse/next_line.hpp>
24
25 [h1 Expression semantics]
26
27 For any `s` source position and `c` wrapped character the following are
28 equivalent
29
30 get_col<next_line<s, c>>::type
31
32 boost::mpl::int_<1>
33
34 get_line<next_line<s, c>>
35
36 boost::mpl::plus<get_line<s>::type, boost::mpl::int_<1>>
37
38 get_prev_char<next_line<s, c>>::type
39
40 c
41
42 [h1 Example]
43
44 #include <boost/metaparse/next_line.hpp>
45 #include <boost/metaparse/source_position.hpp>
46 #include <boost/metaparse/get_col.hpp>
47 #include <boost/metaparse/get_line.hpp>
48 #include <boost/metaparse/get_prev_char.hpp>
49
50 #include <type_traits>
51
52 using namespace boost::metaparse;
53
54 struct returns_source_position
55 {
56 using type =
57 source_position<
58 std::integral_constant<int, 11>,
59 std::integral_constant<int, 13>,
60 std::integral_constant<char, 'a'>
61 >;
62 };
63
64 struct returns_char
65 {
66 using type = std::integral_constant<char, '\n'>;
67 };
68
69 static_assert(
70 get_col<
71 next_line<
72 source_position<
73 std::integral_constant<int, 11>,
74 std::integral_constant<int, 13>,
75 std::integral_constant<char, 'a'>
76 >,
77 std::integral_constant<char, '\n'>
78 >
79 >::type::value == 1,
80 "it should set the column to 1"
81 );
82
83 static_assert(
84 get_line<
85 next_line<
86 source_position<
87 std::integral_constant<int, 11>,
88 std::integral_constant<int, 13>,
89 std::integral_constant<char, 'a'>
90 >,
91 std::integral_constant<char, '\n'>
92 >
93 >::type::value == 12,
94 "it should increase the line component of the source position"
95 );
96
97 static_assert(
98 get_prev_char<
99 next_line<
100 source_position<
101 std::integral_constant<int, 11>,
102 std::integral_constant<int, 13>,
103 std::integral_constant<char, 'a'>
104 >,
105 std::integral_constant<char, '\n'>
106 >
107 >::type::value == '\n',
108 "it should update the prev char component of the source position"
109 );
110
111 static_assert(
112 get_col<next_line<returns_source_position, returns_char>>::type::value == 1,
113 "it should support lazy evaluation"
114 );
115
116 [endsect]
117