1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // XFAIL: availability-fp_to_chars-missing
13 // The sample code is based on the bug report
14 // https://github.com/llvm/llvm-project/issues/81590
16 // Tests whether this formatter does not fail to compile due to nested concept
22 struct X
: std::variant
<X
*> {
24 constexpr const std::variant
<X
*>& decay() const noexcept
{ return *this; }
28 struct std::formatter
<X
, char> : std::formatter
<std::string
, char> {
29 static constexpr auto format(const X
& x
, auto& ctx
) {
32 auto m
= [&](const X
* t
) { return std::format_to(ctx
.out(), "{}", *t
); };
33 return std::visit(m
, x
.decay());
37 void bug_81590() { (void)std::format("{}", X
{}); }