erichkeane added a comment. Herald added a reviewer: dang. @rsmith pointed out https://eel.is/c++draft/temp#friend-9 which I think is supposed to fix the friend function issues:
> A non-template friend declaration with a requires-clause shall be a > definition. > A friend function template with a constraint that depends on a template > parameter from an enclosing template shall be a definition. > Such a constrained friend function or function template declaration does not > declare the same function or function template as a declaration in any other > scope. To me, this says that template<typename T> struct S { friend void foo() requires true {} }; void bar() { S<int> s; S<float> s2; } Should be perfectly fine, and NOT a redefinition? At least this: https://godbolt.org/z/PaK1Yhn1E seems to show that all 3 compilers get this wrong currently? Or I'm misreading this. It ALSO means that: template<typename T> struct S { template<typename U> friend void foo() requires constriant<T> {} }; void bar() { S<int> s; S<float> s2; } is perfectly fine, and not a redefinition. (CURRENT Clang and GCC get this right, but MSVC seems to get it wrong: https://godbolt.org/z/a7dYezoPW) HOWEVER, By reading the rule, a slightly DIFFERENT version of that template<typename T> struct S { template<typename U> friend void foo() requires constriant<U> {} // No longer relies on the enclosing template }; void bar() { S<int> s; S<float> s2; } Is a redefinition. All 3 compilers diagnose this. https://godbolt.org/z/7qbYsb635 Do I have this right? I'm having trouble figuring out the implementation strategy here. It seems my SemaOverload.cpp changes would need to do special work to get example #1 to work, and I got close on #2 (with the exception of some assert in libc++). And #3 I probably had right? Can someone else read the standard bit there and make sure I got a good spread of the issues and interpreted the prose correctly? Thanks! -Erich CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119544/new/ https://reviews.llvm.org/D119544 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits