https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114841
Bug ID: 114841 Summary: [P0522R0] partial ordering of template template parameters Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jason at gcc dot gnu.org Target Milestone: --- Created attachment 58029 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58029&action=edit WIP patch against r8-7277-g515f874faf4562 In the 2016 CWG discussion of making P0522R0 actually work, I proposed the adjustment that I implemented in r7-5537-g31bfc9b9dd65ec and drafted as <ins>* X is an invented class template with the template parameter list of A, including default arguments, except that during partial ordering (14.5.6.2), for each non-parameter-pack template parameter of A, the corresponding template parameter of X has a default argument which is compatible with any other template-argument.</ins> In a reply, Richard Smith noted that this would wrongly accept this example: template<typename T, typename U> struct match2; template<template<typename A> class t1,typename T> struct match2<t1<T>, typename t1<T>::type > { typedef int type; }; // #5 template<template<typename B, typename C> class t2,typename T0,typename T1> struct match2<t2<T0,T1>, typename t2<T0,T0>::type > { typedef int type; }; // #6 template <class T, class U = T> struct Q { typedef int type; }; match2<Q<int>, int> m; and indeed GCC still chooses #6, which is questionable since t1<T> cannot reasonably be deduced to be both t2<T0,T1> and t2<T0,T0>. I worked on implementing this in 2017 but never finished. His alternative suggestion was still to introduce a default argument, but instead of having it match any other template argument, base the default on the actual arguments, i.e. T1 or T0. I worked on this for a while in 2017 but didn't finish. Now that Clang is implementing this (https://github.com/llvm/llvm-project/pull/89807), it would be nice to finish it up.