cplusplus / cplusplus/draft

[over.match.ctor] Default-initialization and its argument list

Open
#5,447 0 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

Since [over.match.general] p2 says

Each of these contexts defines the set of candidate functions and the list of arguments in its own unique way.

However, [over.match.ctor] is not clear for the argument list of the default-initialization context. [over.match.ctor] only says

The argument list is the expression-list or assignment-expression of the initializer.

Neither expression-list nor assignment-expression can be empty. We should explicitly specify the list for default-initialization. Append that

or empty for default-initialization.

This can clarify [over.match.viable] p2

First, to be a viable function, a candidate function shall have enough parameters to agree in number with the arguments in the list.

  • [...]
  • A candidate function having more than m parameters is viable only if all parameters following the
    mth have default arguments ([dcl.fct.default]). For the purposes of overload resolution, the parameter list is truncated on the right, so that there are exactly m parameters.

And the relative example in [over.match.best.general] 2.7

struct A {
  A(int = 0);
};

struct B: A {
  using A::A;
  B();
};

int main() {
  B b;              // OK, B​::​B()
}

we expect the number of the arguments in the list is zero in the default-initialization, therefore A::A(int) is considered to have zero parameters for the purpose of the overload resolution as per [over.match.viable] p2.

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 by locating the [over.match.ctor] wording in the draft source, then compare its argument-list definition with [over.match.viable] p2 and [over.match.best.general] 2.7. Update the wording to explicitly cover an empty list for default-initialization and verify that the B example and overload-resolution rules are consistent.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.