[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 21:24:18 PDT 2024


mizvekov wrote:

@eaeltsin You example boils down to https://godbolt.org/z/axnanxP1z:
```C++
template <class> struct xtype_for_shape;
template <template <class, long> class S, class X, long N>
struct xtype_for_shape<S<X, N>> {};

template <class, bool> struct svector;
template struct xtype_for_shape<svector<int, false>>;
```
There is wide divergence between implementations on what happens during deduction, at least when NTTPs are involved.

clang picks the partial specialization, all other implementations pick the primary template.
This is not something new from this PR either.

The other implementations reject the matching in deduction, but all implementations agree that it would work if directly specified: https://godbolt.org/z/Gfs3dbYEe

(discounting EDG which doesn't seem to implement P0522R0 at all).

I think what clang does makes the most sense; I see no point in having deduction be more strict than the matching itself.

Also, you can create a similar situation with NTTPs where this adds new ambiguity: https://godbolt.org/z/cWPM7jWvd

https://github.com/llvm/llvm-project/pull/89807


More information about the cfe-commits mailing list