cplusplus / cplusplus/draft

[temp.arg.explicit] doesn't allow converting arguments if they deduced template parameters in non-deduced context

Open
#5,115 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

Observation

https://github.com/cplusplus/draft/blob/02f9bb582cadedc590f9eddf7252bf6c327089df/source/templates.tex#L6895-L6899

This wording does not allow conversion in the argument if the parameter contains template parameters in non-deduced context, but they are otherwise deduced.

Expectation

The wording to allow conversion if all the template parameters in the function parameter are explicitly specified or appear in non-deduced context.

Examples

Example 1
#include <type_traits>

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

template <typename T>
void bar(A<std::type_identity_t<T>>, A<T>);

void foo() {
    bar(42, A<int>{}); // conversion from int to A<int> in the first argument

In the example the first parameter contains the template parameter T, and T participates in template argument deduction. So the wording doesn't enable implicit conversion in that argument.

Compilers seem to agree that conversion is allowed there: https://godbolt.org/z/aPdK64zeG

Example 2

There is a similar example in the standard too:

https://github.com/cplusplus/draft/blob/02f9bb582cadedc590f9eddf7252bf6c327089df/source/templates.tex#L8481-L8498

Here the conversion happens in the first argument.

Suggestion

I suggest to replace the wording with the following:

Implicit conversions ([conv]) will be performed on a function argument to convert it to the type of the corresponding function parameter if all the template-parameters it contains are explicitly specified or appear in non-deduced context.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in source/templates.tex at the linked [temp.arg.explicit] wording and read the surrounding paragraphs. Compare it with the linked standard example and the two supplied C++ examples, then update the wording so the described conversions are permitted and verify the draft reflects the intended rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.