@@ -10,10 +10,14 @@ namespace std {
10
10
void println(format_string<Args...> fmt,
11
11
Args&&... args); // (1) C++23
12
12
13
+ void println(); // (2) C++26
14
+
13
15
template <class... Args>
14
16
void println(FILE* stream,
15
17
format_string<Args...> fmt,
16
- Args&&... args); // (2) C++23
18
+ Args&&... args); // (3) C++23
19
+
20
+ void println(FILE* stream); // (4) C++26
17
21
}
18
22
```
19
23
* format_string[link /reference/format/basic_format_string.md]
@@ -27,7 +31,9 @@ namespace std {
27
31
この関数は、[`std::printf()`](/reference/cstdio/printf.md.nolink)関数ライクな書式指定で引数を文字列化して出力する。
28
32
29
33
- (1) : 標準出力に、書式指定で出力する
30
- - (2) : 指定された[`FILE`](/reference/cstdio/file.md.nolink)に、書式指定で出力する
34
+ - (2) : 標準出力に改行コードを出力する
35
+ - (3) : 指定された[`FILE`](/reference/cstdio/file.md.nolink)に、書式指定で出力する
36
+ - (4) : 指定された[`FILE`](/reference/cstdio/file.md.nolink)に、改行コードを出力する
31
37
32
38
この関数は、末尾に改行コードが付くことに注意。改行コードが不要な場合は、[`std::print()`](print.md)関数を使用すること。
33
39
@@ -43,13 +49,25 @@ namespace std {
43
49
* std::forward[link /reference/utility/forward.md]
44
50
45
51
- (2) : 以下と等価:
52
+ ```cpp
53
+ println(stdout);
54
+ ```
55
+ * stdout[link /reference/cstdio/stdout.md.nolink]
56
+
57
+ - (3) : 以下と等価:
46
58
```cpp
47
59
print(stream, "{}\n", format(fmt, std::forward<Args>(args)...));
48
60
```
49
61
* print[link print.md]
50
62
* format[link /reference/format/format.md]
51
63
* std::forward[link /reference/utility/forward.md]
52
64
65
+ - (4) : 以下と等価:
66
+ ```cpp
67
+ print(stream, "\n");
68
+ ```
69
+ * print[link print.md]
70
+
53
71
54
72
## 例
55
73
### 基本的な使い方
@@ -113,6 +131,27 @@ int main()
113
131
Hello
114
132
```
115
133
134
+
135
+ ### 改行コードを出力する (C++26)
136
+ ``` cpp example
137
+ #include < print>
138
+
139
+ int main ()
140
+ {
141
+ std::print ("abc");
142
+ std::println (); // 改行コードのみを出力する
143
+ std::print ("{}", 123);
144
+ std::println ();
145
+ }
146
+ ```
147
+ * std::print[ link print.md]
148
+
149
+ #### 出力
150
+ ```
151
+ abc
152
+ 123
153
+ ```
154
+
116
155
## バージョン
117
156
### 言語
118
157
- C++23
@@ -132,3 +171,4 @@ Hello
132
171
133
172
## 参照
134
173
- [ P2093R14 Formatted output] ( https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2093r14.html )
174
+ - [ P3142R0 Printing Blank Lines with ` println ` ] ( https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3142r0.pdf )
0 commit comments