Issue 60231
Summary Out-of-line definition of member with trailing-requires in template head referring the class is not accepted
Labels new issue
Assignees
Reporter usx95
    https://godbolt.org/z/ns4Kq47o3
```cpp
template<typename T> concept C = true;

template <typename T>
struct Foo {
  // Error: Trailing requires to template referring to Foo.
  template <typename F> requires C<Foo<T>>
  void M1(F f);
  
  // OK: Same but requires attached to decl.
  template <typename F>
  void M2(F f) requires C<Foo<T>>;

  // OK: Same but requires does not refer to `Foo`.
  template <typename F> requires C<F>
  void M3(F f);
};

template <typename T>
template <typename F> requires C<Foo<T>>
void Foo<T>::M1(F f) {}

template <typename T>
template <typename F>
void Foo<T>::M2(F f) requires C<Foo<T>> {}

template <typename T>
template <typename F> requires C<F>
void Foo<T>::M3(F f) {}
```
fails only for M1 with:
```
error: out-of-line definition of 'M1' does not match any declaration in 'Foo<T>'
void Foo<T>::M1(F f) {}
```
Related issues: 
* https://github.com/llvm/llvm-project/issues/49620 but not be a duplicate as the strategy/resolution discussed there is not applicable to trailing requires and only to constrained template parameter.

* https://github.com/llvm/llvm-project/issues/47364 looks more closely related because of trailing requires attached to template head.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to