forked from cplusplus/fundamentals-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreflection.html
132 lines (107 loc) · 5.13 KB
/
reflection.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<cxx-clause id="reflection">
<h1>Reflection library</h1>
<cxx-section id="reflection.src_loc">
<h1>Class <code>source_location</code></h1>
<cxx-section id="reflection.src_loc.synop">
<h1>Header <code><experimental/source_location></code> synopsis</h1>
<pre><code>namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
struct source_location {
<cxx-ref insynopsis to="reflection.src_loc.creation"></cxx-ref>
static constexpr source_location current() noexcept;
constexpr source_location() noexcept;
<cxx-ref insynopsis to="reflection.src_loc.fields"></cxx-ref>
constexpr uint_least32_t line() const noexcept;
constexpr uint_least32_t column() const noexcept;
constexpr const char* file_name() const noexcept;
constexpr const char* function_name() const noexcept;
};
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std</code></pre>
<p>
<cxx-note>The intent of <code>source_location</code> is to have a small size and efficient copying.</cxx-note>
</p>
</cxx-section>
<cxx-section id="reflection.src_loc.creation">
<h1><code>source_location</code> creation</h1>
<cxx-function>
<cxx-signature>static constexpr source_location current() noexcept;</cxx-signature>
<cxx-returns>
When invoked by a function call (<cxx-ref in="cxx" to="expr.call"></cxx-ref>)
whose <cxx-grammarterm>postfix-expression</cxx-grammarterm> is
a (possibly parenthesized) <cxx-grammarterm>id-expression</cxx-grammarterm> naming <code>current</code>,
returns a <code>source_location</code> with an implementation-defined value.
The value should be affected by <code>#line</code>
(<cxx-ref in="cxx" to="cpp.line"></cxx-ref>) in the same manner as for <code>__LINE__</code> and <code>__FILE__</code>.
If invoked in some other way, the value returned is unspecified.
</cxx-returns>
<cxx-remarks>
When a <cxx-grammarterm>brace-or-equal-initializer</cxx-grammarterm> is used to initialize a non-static data member,
any calls to <code>current</code> should correspond to the location of
the constructor or aggregate initialization that initializes the member.
</cxx-remarks>
<p>
<cxx-note>When used as a default argument (<cxx-ref in="cxx" to="dcl.fct.default"></cxx-ref>),
the value of the <code>source_location</code> will be the location of the call to <code>current</code> at the call site.</cxx-note>
</p>
<cxx-example>
<pre><code>struct s {
source_location member = source_location::current();
int other_member;
s(source_location loc = source_location::current())
: member(loc) // <i>values of</i> member <i>will be from call-site</i>
{}
s(int blather) : // <i>values of</i> member <i>should be hereabouts</i>
other_member(blather) {}
s(double) // <i>values of</i> member <i>should be hereabouts</i>
{}
};
void f(source_location a = source_location::current()) {
source_location b = source_location::current(); // <i>values in</i> b <i>represent this line</i>
}
void g() {
f(); // f<i>’s first argument corresponds to this line of code</i>
source_location c = source_location::current();
f(c); // f<i>’s first argument gets the same values as </i>c<i>, above</i>
}</code></pre>
</cxx-example>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr source_location() noexcept;</cxx-signature>
<cxx-effects>Constructs an object of class <code>source_location</code>.</cxx-effects>
<cxx-remarks>The values are implementation-defined.</cxx-remarks>
</cxx-function>
</cxx-section>
<cxx-section id="reflection.src_loc.fields">
<h1><code>source_location</code> field access</h1>
<cxx-function>
<cxx-signature>constexpr uint_least32_t line() const noexcept;</cxx-signature>
<cxx-returns>The presumed line number (<cxx-ref in="cxx" to="cpp.predefined"></cxx-ref>) represented by this object.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr uint_least32_t column() const noexcept;</cxx-signature>
<cxx-returns>
An implementation-defined value representing
some offset from the start of the line represented by this object.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr const char* file_name() const noexcept;</cxx-signature>
<cxx-returns>
The presumed name of the current source file (<cxx-ref in="cxx" to="cpp.predefined"></cxx-ref>)
represented by this object as an NTBS.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr const char* function_name() const noexcept;</cxx-signature>
<cxx-returns>
If this object represents a position in the body of a function,
returns an implementation-defined NTBS that should correspond to the function name.
Otherwise, returns an empty string.
</cxx-returns>
</cxx-function>
</cxx-section>
</cxx-section>
</cxx-clause>