[temp.func.order] Making the intent of transformations clearer
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
The wording of [temp.func.order]/3
To produce the transformed template, for each type, constant, type template, variable template, or concept template parameter (including template parameter packs ([temp.variadic]) thereof) synthesize a unique type, value, class template, variable template, or concept, respectively, and substitute it for each occurrence of that parameter in the function type of the template.
is vague and leaves the precise nature of the transformed function type to be easily misunderstood. Consider, for example:
template <typename T>
void f(T, typename std::type_identity_t<T>);
Intuitively, one might expect the transformed function type to be
void (A, A)
where A is some unique invented type. However, the intention seems to be that the transformed function type in this case becomes
void (A, B)
where A and B are distinct invented types. i.e., the transformation performs substitution only, type-specifiers that would require template instantiation to resolve are considered to give rise to distinct types of their own.
We would suggest to add a note of this fact and, ideally, some examples to illustrate this key issue. e.g.:
#include <type_traits>
template <typename T> void f(T, T); // #1
template <typename T> void f(T, std::type_identity_t<T>); // #2, less specialized than #1
template <typename T> using identity_t = T;
template <typename T> void f(T, identity_t<T>); // redeclaration of #1
Big thanks to @michael-kenzel for the explanation and the example.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at [temp.func.order]/3 and review the existing wording against the issue's T, std::type_identity_t, and identity_t examples. Clarify that the transformation is substitution-only and that unresolved type-specifiers produce distinct invented types; done when the note and examples make the intended ordering behavior unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100