| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | #include <format> |
| 4 | |
| 5 | template<typename Context> |
| 6 | concept format_context_reqs = std::is_destructible_v<Context> |
| 7 | && (!std::is_default_constructible_v<Context>) |
| 8 | && (!std::is_copy_constructible_v<Context>) |
| 9 | && (!std::is_move_constructible_v<Context>) |
| 10 | && (!std::is_copy_assignable_v<Context>) |
| 11 | && (!std::is_move_assignable_v<Context>) |
| 12 | && requires (Context& ctx, const Context& cctx) { |
| 13 | typename Context::iterator; |
| 14 | typename Context::char_type; |
| 15 | requires std::same_as<typename Context::template formatter_type<int>, |
| 16 | std::formatter<int, typename Context::char_type>>; |
| 17 | { ctx.locale() } -> std::same_as<std::locale>; |
| 18 | { ctx.out() } -> std::same_as<typename Context::iterator>; |
| 19 | { ctx.advance_to(ctx.out()) } -> std::same_as<void>; |
| 20 | { cctx.arg(1) } -> std::same_as<std::basic_format_arg<Context>>; |
| 21 | }; |
| 22 | |
| 23 | template<typename Out, typename charT> |
| 24 | constexpr bool |
| 25 | check(std::basic_format_context<Out, charT>*) |
| 26 | { |
| 27 | using context = std::basic_format_context<Out, charT>; |
| 28 | static_assert( format_context_reqs<context> ); |
| 29 | static_assert( std::is_same_v<typename context::iterator, Out> ); |
| 30 | static_assert( std::is_same_v<typename context::char_type, charT> ); |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | static_assert( check( (std::format_context*)nullptr) ); |
| 35 | static_assert( check( (std::wformat_context*)nullptr) ); |
| 36 | static_assert( check( (std::basic_format_context<char*, char>*)nullptr) ); |