Skip to content

Commit adb5fad

Browse files
committed
Add the reflection clause, forgotten in the previous commit.
1 parent 5b1db9b commit adb5fad

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

reflection.html

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

0 commit comments

Comments
 (0)