Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xmh0511 opened this issue May 5, 2022 · 0 comments
Open

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

xmh0511 opened this issue May 5, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented May 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant