From Jason Turner

[support.srcloc.class]

Diff to HTML by rtfpessoa

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