blob: 56c18864135af4ca1561bf175d122d8fa8dc2eec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// { dg-do compile { target c++20 } }
// BasicFormatter requirements do not require a const parameter.
#include <format>
struct X { };
template<> struct std::formatter<X, char>
{
constexpr auto parse(format_parse_context& ctx)
{ return ctx.begin(); }
// Takes non-const X&
format_context::iterator format(X&, format_context& ctx) const
{
auto out = ctx.out();
*out++ = 'x';
return out;
}
};
X x;
auto s = std::format("{}", x);
|