[clang] [clang] require template arg list after template kw (PR #80801)

Davis Herring via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 16:37:32 PST 2024


================
@@ -1414,7 +1414,7 @@ namespace dr96 { // dr96: no
     // FIXME: This is ill-formed, because 'f' is not a template-id and does not
----------------
opensdh wrote:

Yes, P1787R6 deprecated that use case; you're supposed to just not use `template` there.  This is consistent with the _recommendation_ in N1528, but of course we now reject the premise that `template` is _needed_ for a template template argument.  The reasoning, if it helps, is that compilers already have to deal with ambiguity there:
```cpp
template<auto> void f();                                // #1
template<class> void f(int=0);                          // #2
template<template<class> class> void f(void*=nullptr);  // #3

template<class T> void g() {
  // in C++20, [temp.res]/6 and [temp.arg.template]/1 contradict each other here:
  f<T::Q>();             // could be #1 or #3
}
template<class T> struct X {
  // OK per [temp.local]/1
  void h() {f<X>(T());}  // could be #2 or #3
  void i() {T::template R<X>();}  // could be anything
}
```
Accordingly, [CWG1478](https://cplusplus.github.io/CWG/issues/1478.html)'s question was answered in the negative, and `template` (is to be) restricted to the case where it influences the interpretation of a `<`.

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


More information about the cfe-commits mailing list