From Jason Turner

[support.srcloc]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2jdu8moj/{from.md → to.md} +154 -0
tmp/tmp2jdu8moj/{from.md → to.md} RENAMED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Source location <a id="support.srcloc">[[support.srcloc]]</a>
2
+
3
+ ### Header `<source_location>` synopsis <a id="source.location.syn">[[source.location.syn]]</a>
4
+
5
+ The header `<source_location>` defines the class `source_location` that
6
+ provides a means to obtain source location information.
7
+
8
+ ``` cpp
9
+ namespace std {
10
+ struct source_location;
11
+ }
12
+ ```
13
+
14
+ ### Class `source_location` <a id="support.srcloc.class">[[support.srcloc.class]]</a>
15
+
16
+ ``` cpp
17
+ namespace std {
18
+ struct source_location {
19
+ // source location construction
20
+ static consteval source_location current() noexcept;
21
+ constexpr source_location() noexcept;
22
+
23
+ // source location field access
24
+ constexpr uint_least32_t line() const noexcept;
25
+ constexpr uint_least32_t column() const noexcept;
26
+ constexpr const char* file_name() const noexcept;
27
+ constexpr const char* function_name() const noexcept;
28
+
29
+ private:
30
+ uint_least32_t line_; // exposition only
31
+ uint_least32_t column_; // exposition only
32
+ const char* file_name_; // exposition only
33
+ const char* function_name_; // exposition only
34
+ };
35
+ }
36
+ ```
37
+
38
+ The type `source_location` meets the *Cpp17DefaultConstructible*,
39
+ *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, and *Cpp17Destructible*
40
+ requirements [[utility.arg.requirements]]. Lvalues of type
41
+ `source_location` are swappable [[swappable.requirements]]. All of the
42
+ following conditions are `true`:
43
+
44
+ - `is_nothrow_move_constructible_v<source_location>`
45
+ - `is_nothrow_move_assignable_v<source_location>`
46
+ - `is_nothrow_swappable_v<source_location>`
47
+
48
+ [*Note 1*: The intent of `source_location` is to have a small size and
49
+ efficient copying. It is unspecified whether the copy/move constructors
50
+ and the copy/move assignment operators are trivial and/or
51
+ constexpr. — *end note*]
52
+
53
+ The data members `file_name_` and `function_name_` always each refer to
54
+ an NTBS.
55
+
56
+ The copy/move constructors and the copy/move assignment operators of
57
+ `source_location` meet the following postconditions: Given two objects
58
+ `lhs` and `rhs` of type `source_location`, where `lhs` is a copy/move
59
+ result of `rhs`, and where `rhs_p` is a value denoting the state of
60
+ `rhs` before the corresponding copy/move operation, then each of the
61
+ following conditions is `true`:
62
+
63
+ - `strcmp(lhs.file_name(), rhs_p.file_name()) == 0`
64
+ - `strcmp(lhs.function_name(), rhs_p.function_name()) == 0`
65
+ - `lhs.line() == rhs_p.line()`
66
+ - `lhs.column() == rhs_p.column()`
67
+
68
+ #### Creation <a id="support.srcloc.cons">[[support.srcloc.cons]]</a>
69
+
70
+ ``` cpp
71
+ static consteval source_location current() noexcept;
72
+ ```
73
+
74
+ *Returns:*
75
+
76
+ - When invoked by a function call whose *postfix-expression* is a
77
+ (possibly parenthesized) *id-expression* naming `current`, returns a
78
+ `source_location` with an implementation-defined value. The value
79
+ should be affected by `#line` [[cpp.line]] in the same manner as for
80
+ \_\_LINE\_\_ and \_\_FILE\_\_. The values of the exposition-only data
81
+ members of the returned `source_location` object are indicated in
82
+ [[support.srcloc.current]].
83
+ - Otherwise, when invoked in some other way, returns a `source_location`
84
+ whose data members are initialized with valid but unspecified values.
85
+
86
+ *Remarks:* Any call to `current` that appears as a default member
87
+ initializer [[class.mem]], or as a subexpression thereof, should
88
+ correspond to the location of the constructor definition or aggregate
89
+ initialization that uses the default member initializer. Any call to
90
+ `current` that appears as a default argument [[dcl.fct.default]], or as
91
+ a subexpression thereof, should correspond to the location of the
92
+ invocation of the function that uses the default argument [[expr.call]].
93
+
94
+ [*Example 1*:
95
+
96
+ ``` cpp
97
+ struct s {
98
+ source_location member = source_location::current();
99
+ int other_member;
100
+ s(source_location loc = source_location::current())
101
+ : member(loc) // values of member refer to the location of the calling function[dcl.fct.default]
102
+ {}
103
+ s(int blather) : // values of member refer to this location
104
+ other_member(blather)
105
+ {}
106
+ s(double) // values of member refer to this location
107
+ {}
108
+ };
109
+ void f(source_location a = source_location::current()) {
110
+ source_location b = source_location::current(); // values in b refer to this line
111
+ }
112
+
113
+ void g() {
114
+ f(); // f's first argument corresponds to this line of code
115
+
116
+ source_location c = source_location::current();
117
+ f(c); // f's first argument gets the same values as c, above
118
+ }
119
+ ```
120
+
121
+ — *end example*]
122
+
123
+ ``` cpp
124
+ constexpr source_location() noexcept;
125
+ ```
126
+
127
+ The data members are initialized with valid but unspecified values.
128
+
129
+ #### Observers <a id="support.srcloc.obs">[[support.srcloc.obs]]</a>
130
+
131
+ ``` cpp
132
+ constexpr uint_least32_t line() const noexcept;
133
+ ```
134
+
135
+ *Returns:* `line_`.
136
+
137
+ ``` cpp
138
+ constexpr uint_least32_t column() const noexcept;
139
+ ```
140
+
141
+ *Returns:* `column_`.
142
+
143
+ ``` cpp
144
+ constexpr const char* file_name() const noexcept;
145
+ ```
146
+
147
+ *Returns:* `file_name_`.
148
+
149
+ ``` cpp
150
+ constexpr const char* function_name() const noexcept;
151
+ ```
152
+
153
+ *Returns:* `function_name_`.
154
+