| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | // Bug libstdc++/120625 |
| 4 | // std::formatter<__disabled> specializations cause errors in user code |
| 5 | |
| 6 | #include <format> |
| 7 | |
| 8 | enum X { }; |
| 9 | |
| 10 | // A concept that cannot be used with incomplete types: |
| 11 | template<typename T> |
| 12 | concept is_X = !std::is_empty_v<T> && std::is_same_v<X, T>; |
| 13 | |
| 14 | // A valid program-defined specialization: |
| 15 | template<typename T, typename C> requires is_X<T> |
| 16 | struct std::formatter<T, C> : std::formatter<int, C> { }; |
| 17 | |
| 18 | // Instantiate the program-defined formatter specialization: |
| 19 | auto s = sizeof(std::formatter<X, char>); |