]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [#get_line] |
2 | [section get_line] | |
3 | ||
4 | [h1 Synopsis] | |
5 | ||
6 | template <class SourcePosition> | |
7 | struct get_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 | ] | |
15 | ||
16 | [h1 Description] | |
17 | ||
18 | Returns the line of a source position. | |
19 | ||
20 | [h1 Header] | |
21 | ||
22 | #include <boost/metaparse/get_line.hpp> | |
23 | ||
24 | [h1 Expression semantics] | |
25 | ||
26 | For any `l`, `c` compile-time wrapped integral values and `ch` compile-time | |
27 | wrapped character the following are equivalent | |
28 | ||
29 | get_line<source_position<l, c, ch>>::type | |
30 | ||
31 | l::type | |
32 | ||
33 | [h1 Example] | |
34 | ||
35 | #include <boost/metaparse/get_line.hpp> | |
36 | #include <boost/metaparse/source_position.hpp> | |
37 | ||
38 | #include <type_traits> | |
39 | ||
40 | using namespace boost::metaparse; | |
41 | ||
42 | struct returns_source_position | |
43 | { | |
44 | using type = | |
45 | source_position< | |
46 | std::integral_constant<int, 11>, | |
47 | std::integral_constant<int, 13>, | |
48 | std::integral_constant<char, 0> | |
49 | >; | |
50 | }; | |
51 | ||
52 | static_assert( | |
53 | get_line< | |
54 | source_position< | |
55 | std::integral_constant<int, 11>, | |
56 | std::integral_constant<int, 13>, | |
57 | std::integral_constant<char, 0> | |
58 | > | |
59 | >::type::value == 11, | |
60 | "It should return the line of a source position" | |
61 | ); | |
62 | ||
63 | static_assert( | |
64 | get_line<returns_source_position>::type::value == 11, | |
65 | "It should support lazy evaluation" | |
66 | ); | |
67 | ||
68 | ||
69 | [endsect] | |
70 |