Title
Behavior change for class template argument deduction
Status
open
Section
C.2 [diff.cpp20]
Submitter
Christof Meerwald

Created on 2026-04-30.00:00:00 last changed 7 days ago

Messages

Date: 2026-05-05.06:49:22

Possible resolution:

Add a new subclause in C.2 [diff.cpp20] as follows:

C.2.5+ Clause 12: overloading [diff.cpp20.over]

Affected subclause: 12.2.2.9 [over.match.class.deduct]
Change: Deducing class template arguments from inherited constructors.
Rationale: Adding missing feature for class template argument deduction.
Effect on original feature: Valid ISO C++ 2020 code may become ill-formed or change meaning.
[Example 1 :
   template<typename T>
   struct B {
     B(T);
   };

   template<typename T>
   struct D : B<T *> {
     D(T);
     using B<T *>::B;
     T m = "a";   // #1
   };

   D d("");       // ill-formed at #1 (T deduced as const char); previously well-formed (T deduced as const char*)
-- end example]
Date: 2026-04-30.00:00:00

Consider:

   template<typename T>
   struct B {
     B(T);
   };

   template<typename T>
   struct D : B<T *> {
     D(T);
     using B<T *>::B;
     T m = "a";   // #1
   };

   D d("");       // #1 is OK with C++20 (T deduced as const char*), but ill-formed with C++23 (T deduced as const char)
History
Date User Action Args
2026-05-05 06:49:22adminsetmessages: + msg8567
2026-04-30 00:00:00admincreate