diff --git a/reference/format/make_format_args.md b/reference/format/make_format_args.md index 4f4484a98a..326ca50e8a 100644 --- a/reference/format/make_format_args.md +++ b/reference/format/make_format_args.md @@ -9,17 +9,17 @@ namespace std { template format_arg_store - make_format_args(Args&&... args); // (1) C++20 + make_format_args(Args&... args); // (1) C++20 template constexpr format_arg_store - make_format_args(Args&&... args); // (1) C++26 + make_format_args(Args&... args); // (1) C++26 template format_arg_store - make_wformat_args(Args&&... args); // (2) C++20 + make_wformat_args(Args&... args); // (2) C++20 template constexpr format_arg_store - make_wformat_args(Args&&... args); // (2) C++26 + make_wformat_args(Args&... args); // (2) C++26 } ``` * format_arg_store[italic] @@ -79,7 +79,8 @@ return make_format_args(args...); int main() { std::string fmt = "0x{:x} 0b{:04b}"; - std::string s = std::vformat(fmt, std::make_format_args(10, 6)); + int m = 10, n = 6; + std::string s = std::vformat(fmt, std::make_format_args(m, n)); std::cout << s << std::endl; } ``` @@ -124,3 +125,5 @@ namespace std { * [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html) * [P2418R2 Add support for `std::generator`-like types to `std::format`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2418r2.html) +* [P2905R2 Runtime format strings](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2905r2.html) + * C++23 発効後の DR として、引数を非 `const` 左辺値参照とすることで、一時オブジェクトを渡すことによる寿命切れオブジェクトの参照を回避する変更が提案された。これは C++20 まで遡及適用された。 diff --git a/reference/format/vformat.md b/reference/format/vformat.md index 3ecbc595be..113ee744a6 100644 --- a/reference/format/vformat.md +++ b/reference/format/vformat.md @@ -70,7 +70,8 @@ C++26以降は、実行時文字列のフォーマット引数を使用したい int main() { std::string fmt = "0x{:x} 0b{:04b}"; - std::string s = std::vformat(fmt, std::make_format_args(10, 6)); + int m = 10, n = 6; + std::string s = std::vformat(fmt, std::make_format_args(m, n)); std::cout << s << std::endl; } ``` @@ -132,5 +133,6 @@ string vformat(const locale& loc, wstring_view fmt, wformat_args args) { - [Working Draft, Standard for Programming Language C++ [format]](https://timsong-cpp.github.io/cppwp/format) - [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html) +- [P2905R2 Runtime format strings](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2905r2.html) - [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html) - C++26から非ロケール版が`constexpr`に対応した