| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | // LWG 3810. CTAD for std::basic_format_args |
| 4 | |
| 5 | #include <format> |
| 6 | |
| 7 | int x = 1; |
| 8 | long y = 2; |
| 9 | short z = 3; |
| 10 | |
| 11 | auto args_store = std::make_format_args(x, y, z); |
| 12 | std::basic_format_args args = args_store; |
| 13 | static_assert(std::is_same_v<decltype(args), std::format_args>); |
| 14 | |
| 15 | |
| 16 | template<typename Context> |
| 17 | void foo(std::basic_format_args<Context>); |
| 18 | |
| 19 | void |
| 20 | test_ctad() |
| 21 | { |
| 22 | using std::basic_format_args; |
| 23 | using std::make_format_args; |
| 24 | using SomeContext = std::wformat_context; |
| 25 | |
| 26 | // foo(make_format_args<SomeContext>(...)); // won't work |
| 27 | foo(basic_format_args(make_format_args<SomeContext>(x, y, z))); // should work |
| 28 | } |