[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 07:52:36 PDT 2024
================
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++23 -verify %s
+
+namespace t1 {
+template<bool> struct enable_if { typedef void type; };
+template <class T> class Foo {};
+template <class X> constexpr bool check() { return true; }
+template <class X, class Enable = void> struct Bar {};
+
+template<class X> void func(Bar<X, typename enable_if<check<X>()>::type>) {}
+// expected-note at -1 {{candidate function}}
+
+template<class T> void func(Bar<Foo<T>>) {}
+// expected-note at -1 {{candidate function}}
+
+void g() {
+ func(Bar<Foo<int>>()); // expected-error {{call to 'func' is ambiguous}}
----------------
AaronBallman wrote:
I don't have a strong opinion, but when 100% of implementations all do the same thing (which we do), it seems rather silly to expect implementations and users to change instead of asking whether the standard should reflect reality.
https://godbolt.org/z/johT7fva8
I don't see a reason to break user code except for conformance, but *nobody conforms* so...
https://github.com/llvm/llvm-project/pull/100692
More information about the cfe-commits
mailing list