Question Details

No question body available.

Tags

c++ language-lawyer template-argument-deduction

Answers (1)

Accepted Answer Available
Accepted Answer
September 4, 2025 Score: 1 Rep: 778 Quality: High Completeness: 100%

This is an (extended) summary of the comments of me and others.


The standard (C++26 draft) seems to be unclear for this example. It can be read in a way that const int is deduced, or that int is deduced. Clang has the following comment in its source:

// We work around a defect in the standard here: cv-qualifiers are also
// removed from P and A in this case, unless P was a reference type. This
// seems to mostly match what other compilers are doing.

Clang removes const after removing the references from A, and thus deduces int. There is a github issue exactly for this example: https://github.com/cplusplus/draft/issues/5123 (Note: I am not sure, whether github issues are officially considered by the C++ standard committee)

There are similar "official" core issues: